2023-07-01 11:58:00 -04:00
|
|
|
import extensions;
|
|
|
|
|
import extensions'math;
|
|
|
|
|
|
|
|
|
|
randomNormal()
|
|
|
|
|
{
|
2026-02-01 16:33:20 -08:00
|
|
|
^ cos(2 * Pi_value * Random.nextReal())
|
|
|
|
|
* sqrt(-2 * ln(Random.nextReal()))
|
2023-07-01 11:58:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public program()
|
|
|
|
|
{
|
|
|
|
|
real[] a := new real[](1000);
|
|
|
|
|
|
|
|
|
|
real tAvg := 0;
|
2024-03-06 22:25:12 -08:00
|
|
|
for (int x := 0; x < a.Length; x += 1)
|
2023-07-01 11:58:00 -04:00
|
|
|
{
|
|
|
|
|
a[x] := (randomNormal()) / 2 + 1;
|
|
|
|
|
tAvg += a[x]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tAvg /= a.Length;
|
2026-02-01 16:33:20 -08:00
|
|
|
Console.printLine("Average: ", tAvg);
|
2023-07-01 11:58:00 -04:00
|
|
|
|
|
|
|
|
real s := 0;
|
2024-03-06 22:25:12 -08:00
|
|
|
for (int x := 0; x < a.Length; x += 1)
|
2023-07-01 11:58:00 -04:00
|
|
|
{
|
|
|
|
|
s += power(a[x] - tAvg, 2)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
s := sqrt(s / 1000);
|
|
|
|
|
|
2026-02-01 16:33:20 -08:00
|
|
|
Console.printLine("Standard Deviation: ", s);
|
2023-07-01 11:58:00 -04:00
|
|
|
|
2026-02-01 16:33:20 -08:00
|
|
|
Console.readChar()
|
2023-07-01 11:58:00 -04:00
|
|
|
}
|