35 lines
635 B
Text
35 lines
635 B
Text
import extensions;
|
|
import extensions'math;
|
|
|
|
randomNormal()
|
|
{
|
|
^ cos(2 * Pi_value * Random.nextReal())
|
|
* sqrt(-2 * ln(Random.nextReal()))
|
|
}
|
|
|
|
public program()
|
|
{
|
|
real[] a := new real[](1000);
|
|
|
|
real tAvg := 0;
|
|
for (int x := 0; x < a.Length; x += 1)
|
|
{
|
|
a[x] := (randomNormal()) / 2 + 1;
|
|
tAvg += a[x]
|
|
};
|
|
|
|
tAvg /= a.Length;
|
|
Console.printLine("Average: ", tAvg);
|
|
|
|
real s := 0;
|
|
for (int x := 0; x < a.Length; x += 1)
|
|
{
|
|
s += power(a[x] - tAvg, 2)
|
|
};
|
|
|
|
s := sqrt(s / 1000);
|
|
|
|
Console.printLine("Standard Deviation: ", s);
|
|
|
|
Console.readChar()
|
|
}
|