Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View 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;

View file

@ -0,0 +1,67 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. RANDOM.
AUTHOR. Bill Gunshannon
INSTALLATION. Home.
DATE-WRITTEN. 14 January 2022.
************************************************************
** Program Abstract:
** Able to get the Mean to be really close to 1.0 but
** couldn't get the Standard Deviation any closer than
** .3 to .4.
************************************************************
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Sample-Size PIC 9(5) VALUE 1000.
01 Total PIC 9(10)V9(5) VALUE 0.0.
01 Arith-Mean PIC 999V999 VALUE 0.0.
01 Std-Dev PIC 999V999 VALUE 0.0.
01 Seed PIC 999V999.
01 TI PIC 9(8).
01 Idx PIC 99999 VALUE 0.
01 Intermediate PIC 9(10)V9(5) VALUE 0.0.
01 Rnd-Work.
05 Rnd-Tbl
OCCURS 1 TO 99999 TIMES DEPENDING ON Sample-Size.
10 Rnd PIC 9V9999999 VALUE 0.0.
PROCEDURE DIVISION.
Main-Program.
ACCEPT TI FROM TIME.
MOVE FUNCTION RANDOM(TI) TO Seed.
PERFORM WITH TEST AFTER VARYING Idx
FROM 1 BY 1
UNTIL Idx = Sample-Size
COMPUTE Intermediate =
(FUNCTION RANDOM() * 2.01)
MOVE Intermediate TO Rnd(Idx)
END-PERFORM.
PERFORM WITH TEST AFTER VARYING Idx
FROM 1 BY 1
UNTIL Idx = Sample-Size
COMPUTE Total = Total + Rnd(Idx)
END-PERFORM.
COMPUTE Arith-Mean = Total / Sample-Size.
DISPLAY "Mean: " Arith-Mean.
PERFORM WITH TEST AFTER VARYING Idx
FROM 1 BY 1
UNTIL Idx = Sample-Size
COMPUTE Intermediate =
Intermediate + (Rnd(Idx) - Arith-Mean) ** 2
END-PERFORM.
COMPUTE Std-Dev = Intermediate / Sample-Size.
DISPLAY "Std-Dev: " Std-Dev.
STOP RUN.
END PROGRAM RANDOM.

View file

@ -0,0 +1,15 @@
include misc.e
function RandomNormal()
atom x1, x2
x1 = rand(999999) / 1000000
x2 = rand(999999) / 1000000
return sqrt(-2*log(x1)) * cos(2*PI*x2)
end function
constant n = 1000
sequence s
s = repeat(0,n)
for i = 1 to n do
s[i] = 1 + 0.5 * RandomNormal()
end for

View file

@ -0,0 +1,15 @@
require "table2"
local function rand_normal()
return math.sqrt(-2 * math.log(math.random())) * math.cos(2 * math.pi * math.random())
end
local n = 1000
local numbers = table.rep(n, 0)
local mu = 1
local sigma = 0.5
for i = 1, n do
numbers[i] = mu + sigma * rand_normal()
end
print($"Actual mean : {numbers:mean()}")
print($"Actual std dev: {numbers:stddev()}")

View file

@ -0,0 +1,35 @@
function Get-RandomNormal
{
[CmdletBinding()]
Param ( [double]$Mean, [double]$StandardDeviation )
$RandomNormal = $Mean + $StandardDeviation * [math]::Sqrt( -2 * [math]::Log( ( Get-Random -Minimum 0.0 -Maximum 1.0 ) ) ) * [math]::Cos( 2 * [math]::PI * ( Get-Random -Minimum 0.0 -Maximum 1.0 ) )
return $RandomNormal
}
# Standard deviation function for testing
function Get-StandardDeviation
{
[CmdletBinding()]
param ( [double[]]$Numbers )
$Measure = $Numbers | Measure-Object -Average
$PopulationDeviation = 0
ForEach ($Number in $Numbers) { $PopulationDeviation += [math]::Pow( ( $Number - $Measure.Average ), 2 ) }
$StandardDeviation = [math]::Sqrt( $PopulationDeviation / ( $Measure.Count - 1 ) )
return $StandardDeviation
}
# Test
$RandomNormalNumbers = 1..1000 | ForEach { Get-RandomNormal -Mean 1 -StandardDeviation 0.5 }
$Measure = $RandomNormalNumbers | Measure-Object -Average
$Stats = [PSCustomObject]@{
Count = $Measure.Count
Average = $Measure.Average
StandardDeviation = Get-StandardDeviation -Numbers $RandomNormalNumbers
}
$Stats | Format-List

View file

@ -1,4 +1,4 @@
-- 24 Aug 2025
-- 25 Apr 2026
include Setting
say 'RANDOM NUMBERS'
@ -21,10 +21,10 @@ exit
GetUniform:
procedure expose Memo. Work.
arg xx
say 'Get' xx 'uniform distributed Random numbers...'
say 'Get' xx 'uniform distributed random numbers...'
Work. = 0
do n = 1 to xx
Work.n = Randu()
Work.n = Rand12()
end
Work.0 = xx
say 'Done'
@ -34,7 +34,7 @@ return
GetNormal:
procedure expose Memo. Work.
arg xx
say 'Get' xx 'normal(1,1/2) distributed Random numbers...'
say 'Get' xx 'normal(1,1/2) distributed random numbers...'
Work. = 0
do n = 1 to xx
Work.n = Randn(1,0.5)
@ -56,19 +56,10 @@ return
ShowStats:
procedure expose Memo. Work.
say 'Statistics for' Work.0 'items...'
sum = 0
do n = 1 to Work.0
sum = sum+Work.n
end
avg = sum/Work.0
sum = 0
do n = 1 to Work.0
sum = sum+(Work.n-avg)**2
end
varia = sum/Work.0; stdev = SqRt(varia)/1
say 'Average ' Std(avg)
say 'Deviation' Std(stdev)
say 'Variance ' Std(varia)
parse value StatsSt('Work.') with mean dev vari
say 'Average ' mean
say 'Deviation' dev
say 'Variance ' vari
say
return
@ -81,4 +72,5 @@ say 'Variance ' 1/12 '(1/12)'
say
return
-- Rand12: Randn; StatsSt; Std; Sqrt; Timer
include Math

View file

@ -0,0 +1,13 @@
let pi = 4.0 *. atan(1.0)
let random_gaussian = () => {
1.0 +.
sqrt(-2.0 *. log(Random.float(1.0))) *.
cos(2.0 *. pi *. Random.float(1.0))
}
let a = Belt.Array.makeBy(1000, (_) => random_gaussian ())
for i in 0 to 10 {
Js.log(a[i])
}

View file

@ -1,6 +1,6 @@
# Generate normal distribution with mean = 1, sd = 0.5
Gauss ← (×(∿+η××2π⚂) (√ׯ2ₙe⚂))
[⍥(+1×0.5Gauss)1000] # -> mean = 1, sd = 0.5
Gauss ← (×(∿+η×2π⚂) (√ׯ2°ₑ⚂))
⍥(+1×0.5Gauss)1000 # -> mean = 1, sd = 0.5
Mean ← ÷⧻⟜/+
Sd ← √÷⊃(⋅⧻|/+×.-)Mean.
⊸⊃Sd Mean
Sd ← √÷⊃(⋅⧻|/+˙×-)Mean
⊸⊃Mean Sd