35 lines
907 B
Plaintext
35 lines
907 B
Plaintext
module Modified_random_distribution (f, m, bins){
|
|
form 60, 32
|
|
Cls 1, 0
|
|
Report "Modified Random Distribution"
|
|
Cls 0, 1
|
|
Cursor 0, 5
|
|
T$="Range Istogram"
|
|
Print #f, T$
|
|
Print T$
|
|
double a[bins]
|
|
def modifier(x) = if(x < 0.5-> 1-2*x, 2*x -1)
|
|
for i=1 to m
|
|
while True:
|
|
random1 = rnd
|
|
random2 = rnd
|
|
if random2 < modifier(random1) then
|
|
answer = int(random1*bins)
|
|
a[answer]++
|
|
exit
|
|
end if
|
|
end while
|
|
next
|
|
b=100 / bins
|
|
|
|
for i=0 to bins-1
|
|
L$=format$("{0:1:-4} - {1:1:-4} {2} {3}% ",i*b,(i+1)*b-.1, string$("*",a[i]/(m/bins)*20), round(a[i]/m*100,2))
|
|
Print #f, L$
|
|
Print L$
|
|
next
|
|
}
|
|
// Ansi file / use for wide output for UTF16LE
|
|
Open "ModRandomDistr.txt" for output as #f
|
|
Modified_random_distribution f, 10000, 21
|
|
close #f
|