36 lines
653 B
Plaintext
36 lines
653 B
Plaintext
import extensions;
|
|
import extensions'math;
|
|
|
|
randomNormal()
|
|
{
|
|
^ cos(2 * Pi_value * randomGenerator.nextReal())
|
|
* sqrt(-2 * ln(randomGenerator.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()
|
|
}
|