Random numbers: Difference between revisions
→{{header|FutureBasic}}
m (Applesoft BASIC) |
|||
Line 1,081:
Note: To generate the random number, rather than using FB's native "rnd" function, this code wraps C code into the RandomZeroToOne function.
<lang futurebasic>
window 1
local fn RandomZeroToOne as double
Line 1,093:
dim as double r
r = fn RandomZeroToOne
end fn = 1 + .5 * ( sqr( -2 * log(r) ) * cos( 2 * pi * r ) )
for i = 1 to 1000
next
mean = mean / 1000
for i = 1 to 1000
next
std = std / 1000
print " Average: "; mean
print "Standard Deviation: "; std
HandleEvents
</pre>
|