Random numbers: Difference between revisions
m
→{{header|FutureBasic}}
m (→{{header|R}}) |
|||
Line 1,080:
=={{header|FutureBasic}}==
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
cln result = (double)( (rand() % 100000 ) * 0.00001 );▼
▲ result = (double)( (rand() % 100000 ) * 0.00001 );
end fn = result
local fn RandomGaussian as double
end fn = 1 + .5 * ( sqr( -2 * log(r) ) * cos( 2 * pi * r ) )
Line 1,100 ⟶ 1,095:
for i = 1 to 1000
a(i) = fn RandomGaussian
mean += a(i)
next
mean = mean / 1000
for i = 1 to 1000
std += ( a(i) - mean )^2
next
std = std / 1000
Line 1,113 ⟶ 1,108:
print "Standard Deviation: "; std
HandleEvents</lang>
=={{header|Go}}==
|