42 lines
718 B
Plaintext
42 lines
718 B
Plaintext
call sample 100
|
|
call sample 1000
|
|
call sample 10000
|
|
|
|
end
|
|
|
|
sub sample n
|
|
dim dat( n)
|
|
for i =1 to n
|
|
dat( i) =rnd( 1)
|
|
next i
|
|
|
|
'// show mean, standard deviation
|
|
sum =0
|
|
sSq =0
|
|
for i =1 to n
|
|
sum =sum +dat( i)
|
|
sSq =sSq +dat( i)^2
|
|
next i
|
|
print n; " data terms used."
|
|
|
|
mean =sum / n
|
|
print "Mean ="; mean
|
|
|
|
print "Stddev ="; ( sSq /n -mean^2)^0.5
|
|
|
|
'// show histogram
|
|
nBins =10
|
|
dim bins( nBins)
|
|
for i =1 to n
|
|
z =int( nBins *dat( i))
|
|
bins( z) =bins( z) +1
|
|
next i
|
|
for b =0 to nBins -1
|
|
for j =1 to int( nBins *bins( b)) /n *70)
|
|
print "#";
|
|
next j
|
|
print
|
|
next b
|
|
print
|
|
end sub
|