Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Random-numbers/Elena/random-numbers.elena
Normal file
35
Task/Random-numbers/Elena/random-numbers.elena
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue