Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Random-numbers/Ada/random-numbers.ada
Normal file
23
Task/Random-numbers/Ada/random-numbers.ada
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
with Ada.Numerics; use Ada.Numerics;
|
||||
with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random;
|
||||
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
|
||||
|
||||
procedure Normal_Random is
|
||||
function Normal_Distribution
|
||||
( Seed : Generator;
|
||||
Mu : Float := 1.0;
|
||||
Sigma : Float := 0.5
|
||||
) return Float is
|
||||
begin
|
||||
return
|
||||
Mu + (Sigma * Sqrt (-2.0 * Log (Random (Seed), 10.0)) * Cos (2.0 * Pi * Random (Seed)));
|
||||
end Normal_Distribution;
|
||||
|
||||
Seed : Generator;
|
||||
Distribution : array (1..1_000) of Float;
|
||||
begin
|
||||
Reset (Seed);
|
||||
for I in Distribution'Range loop
|
||||
Distribution (I) := Normal_Distribution (Seed);
|
||||
end loop;
|
||||
end Normal_Random;
|
||||
Loading…
Add table
Add a link
Reference in a new issue