1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
disgnaIstogrammi(viewPort, valueToDictionarys(n, m, index13a)); public Tuple<Dictionary<double, int>, Dictionary<decimal, int>, Dictionary<decimal, int>> valueToDictionarys(int m, int n, int index13a)
{
Dictionary<double, List<double>> randomvalues = new Dictionary<double, List<double>>();
int i = 0;
int j = 0;
//calcolation of the random ditribution
for (i = 0; i < n; i++)
{
List<Double> tmp = new List<double>();
tmp = distrubution.values[i];
randomvalues.Add(i, tmp);
}
//controllo se è da fare exp squred o squared/ squared
if (index13a != 0)
{
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
{
if (index13a == 1) randomvalues[i][j] = Math.Pow(Math.E, randomvalues[i][j]);
if (index13a == 2) randomvalues[i][j] = Math.Pow(randomvalues[i][j], 2);
if (index13a == 3) randomvalues[i][j] = Math.Pow(randomvalues[i][j], 2);
}
if (index13a == 3)
{
NormalPathfinder distribution2 = new NormalPathfinder(n, m);
Dictionary<double, List<double>> otherones = new Dictionary<double, List<double>>();
for (i = 0; i < n; i++)
{
List<Double> tmp = new List<double>();
tmp = distribution2.values[i];
otherones.Add(i, tmp);
for (j = 0; j < m; j++)
{
otherones[i][j]= Math.Pow(otherones[i][j], 2);
randomvalues[i][j] = randomvalues[i][j] / otherones[i][j];
}
}
}
}
Dictionary<double, int> randomdistrib = new Dictionary<double, int>();
Dictionary<decimal, int> meanValues = new Dictionary<decimal, int>();
Dictionary<decimal, int> varValues = new Dictionary<decimal, int>();
for (double k = -1.0; k <= 1.0000; k = k + 0.100)
{
foreach (var list in randomvalues)
{
foreach (var elem in list.Value)
{
if (elem > k && elem <= (k + 0.1))
{
int tmp = 1;
if (randomdistrib.TryGetValue(k, out tmp)) { randomdistrib.Remove(k); tmp++; }
randomdistrib.Add(k, tmp);
}
}
}
}
foreach (var list in randomvalues)
{
double mean = 0;
double variance = 0;
foreach (var elem in list.Value)
{
mean = mean + (elem - mean);
}
foreach (var elem in list.Value)
{
variance = variance + ((elem - mean) * (elem - mean));
}
mean = mean - (mean % 0.1);
variance = variance - (variance % 2);
int tmp2 = 1;
if (meanValues.TryGetValue((decimal)mean, out tmp2)) { meanValues.Remove((decimal)mean); tmp2++; }
meanValues.Add((decimal)mean, tmp2);
tmp2 = 1;
if (varValues.TryGetValue((decimal)variance, out tmp2)) { varValues.Remove((decimal)variance); tmp2++; }
varValues.Add((decimal)variance, tmp2);
}
return new Tuple<Dictionary<double, int>, Dictionary<decimal, int>, Dictionary<decimal, int>>(randomdistrib, meanValues, varValues);
}
|