43 lines
893 B
Plaintext
43 lines
893 B
Plaintext
s = 100000
|
|
h$ = "============================================================="
|
|
h$ = h$ + h$
|
|
dim ndis(s)
|
|
' mean and standard deviation.
|
|
mx = -9999
|
|
mn = 9999
|
|
sum = 0
|
|
sumSqr = 0
|
|
for i = 1 to s ' find minimum and maximum
|
|
ms = rnd(1)
|
|
ss = rnd(1)
|
|
nd = (-2 * log(ms))^0.5 * cos(2 *3.14159265 * ss) ' normal distribution
|
|
ndis(i) = nd
|
|
mx = max(mx, nd)
|
|
mn = min(mn, nd)
|
|
sum = sum + nd
|
|
sumSqr = sumSqr + nd ^ 2
|
|
next i
|
|
|
|
mean = sum / s
|
|
range = mx - mn
|
|
|
|
print "Samples :"; s
|
|
print "Largest :"; mx
|
|
print "Smallest :"; mn
|
|
print "Range :"; range
|
|
print "Mean :"; mean
|
|
print "Stand Dev :"; (sumSqr /s -mean^2)^0.5
|
|
|
|
'Show chart of histogram
|
|
nBins = 50
|
|
dim bins(nBins)
|
|
for i = 1 to s
|
|
z = int((ndis(i) -mn) /range *nBins)
|
|
bins(z) = bins(z) + 1
|
|
mb = max(bins(z),mb)
|
|
next i
|
|
for b = 0 to nBins -1
|
|
print using("##",b);" ";using("#####",bins(b));" ";left$(h$,(bins(b) / mb) * 90)
|
|
next b
|
|
END
|