Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
call sample 100000
|
||||
|
||||
end
|
||||
|
||||
sub sample n
|
||||
dim dat( n)
|
||||
for i =1 to n
|
||||
dat( i) =normalDist( 1, 0.2)
|
||||
next i
|
||||
|
||||
'// show mean, standard deviation. Find max, min.
|
||||
mx =-1000
|
||||
mn = 1000
|
||||
sum =0
|
||||
sSq =0
|
||||
for i =1 to n
|
||||
d =dat( i)
|
||||
mx =max( mx, d)
|
||||
mn =min( mn, d)
|
||||
sum =sum +d
|
||||
sSq =sSq +d^2
|
||||
next i
|
||||
print n; " data terms used."
|
||||
|
||||
mean =sum / n
|
||||
print "Largest term was "; mx; " & smallest was "; mn
|
||||
range =mx -mn
|
||||
print "Mean ="; mean
|
||||
|
||||
print "Stddev ="; ( sSq /n -mean^2)^0.5
|
||||
|
||||
'// show histogram
|
||||
nBins =50
|
||||
dim bins( nBins)
|
||||
for i =1 to n
|
||||
z =int( ( dat( i) -mn) /range *nBins)
|
||||
bins( z) =bins( z) +1
|
||||
next i
|
||||
for b =0 to nBins -1
|
||||
for j =1 to int( nBins *bins( b)) /n *30)
|
||||
print "#";
|
||||
next j
|
||||
print
|
||||
next b
|
||||
print
|
||||
end sub
|
||||
|
||||
function normalDist( m, s) ' Box Muller method
|
||||
u =rnd( 1)
|
||||
v =rnd( 1)
|
||||
normalDist =( -2 *log( u))^0.5 *cos( 2 *3.14159265 *v)
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue