Data update
This commit is contained in:
parent
52a6ef48dd
commit
157b70a810
604 changed files with 14253 additions and 2100 deletions
|
|
@ -2,13 +2,13 @@ BEGIN # Modified random distribution - translation of the Wren sample #
|
|||
|
||||
next random; # initialise the random number generator #
|
||||
|
||||
PROC rng = ( PROC(REAL)REAL modifier )REAL:
|
||||
PROC rng = ( PROC(REAL)REAL modifier fn )REAL:
|
||||
BEGIN
|
||||
REAL r1, r2;
|
||||
WHILE
|
||||
r1 := random;
|
||||
r2 := random;
|
||||
r2 >= modifier( r1 )
|
||||
r2 >= modifier fn( r1 )
|
||||
DO SKIP OD;
|
||||
r1
|
||||
END # rng # ;
|
||||
|
|
@ -21,7 +21,7 @@ BEGIN # Modified random distribution - translation of the Wren sample #
|
|||
CHAR hist char = "#";
|
||||
INT hist char size = 125;
|
||||
[ 0 : num bins - 1 ]INT bins ; FOR i FROM LWB bins TO UPB bins DO bins[ i ] := 0 OD;
|
||||
FOR i FROM 0 TO n DO
|
||||
FROM 0 TO n DO
|
||||
bins[ ENTIER ( rng( modifier ) / bin size ) ] +:= 1
|
||||
OD;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
include xpllib; \for Print
|
||||
|
||||
func real Modifier(X);
|
||||
real X;
|
||||
return if X < 0.5 then 2.*(0.5-X) else 2.*(X-0.5);
|
||||
|
||||
func real RGen;
|
||||
return float(Ran(1_000_000)) / 1e6;
|
||||
|
||||
func real RNG;
|
||||
real R1, R2;
|
||||
[loop [R1:= RGen;
|
||||
R2:= RGen;
|
||||
if R2 < Modifier(R1) then
|
||||
return R1;
|
||||
];
|
||||
];
|
||||
|
||||
def N = 100_000;
|
||||
def NUM_BINS = 20;
|
||||
def HIST_CHAR = ^#;
|
||||
def HIST_CHAR_SIZE = 125;
|
||||
def BinSize = 1. / float(NUM_BINS);
|
||||
int Bins(NUM_BINS), BN, I, J, Hist;
|
||||
real RN;
|
||||
[for I:= 0 to N-1 do
|
||||
[RN:= RNG;
|
||||
BN:= fix(Floor(RN/BinSize));
|
||||
Bins(BN):= Bins(BN)+1;
|
||||
];
|
||||
Print("Modified random distribution with %,d samples in range [0, 1):\n", N);
|
||||
Print(" Range Number of samples within that range\n");
|
||||
for I:= 0 to NUM_BINS-1 do
|
||||
[Hist:= Bins(I) / HIST_CHAR_SIZE;
|
||||
Print("%1.2f ..< %1.2f ", BinSize*float(I), BinSize*float(I+1));
|
||||
for J:= 1 to Hist do Print("%c", HIST_CHAR);
|
||||
Print(" %,d\n", Bins(I));
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue