File: statistics.mpi

package info (click to toggle)
mathpiper 0.0.svn2556-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 7,416 kB
  • ctags: 2,729
  • sloc: java: 21,643; xml: 751; sh: 105; makefile: 5
file content (21 lines) | stat: -rw-r--r-- 457 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Mean(x) := Add(x)/Length(x);

GeometricMean(x) := Factorize(x)^(1/Length(x));

Median(x) :=
[
 Local(sx,n,n2); // s[orted]x
 sx := BubbleSort(x,"<");
 n := Length(x);
 n2 := (n>>1);
 If(Mod(n,2) = 1, sx[n2+1], (sx[n2]+sx[n2+1])/2);
];

Variance(x) := Add((x-Mean(x))^2)/Length(x);
UnbiasedVariance(x) := Add((x-Mean(x))^2)/(Length(x)-1);

// stdev in Wester benchmark
StandardDeviation(x) := Sqrt(UnbiasedVariance(x)); 
// Why Sqrt(1.01) --> Sqrt(1.01) ?