Random numbers: Difference between revisions

expand task description, fix whitespace
(convert to Header template)
(expand task description, fix whitespace)
Line 2:
 
The goal of this task is to generate a 1000-element array (vector, list, whatever it's called in your language) filled with normally distributed random numbers with a mean of 1.0 and a [http://en.wikipedia.org/wiki/Standard_deviation standard deviation] of 0.5
 
Many libraries only generate uniformly distributed random numbers. If so, use [http://en.wikipedia.org/wiki/Normal_distribution#Generating_values_for_normal_random_variables this formula] to convert them to a normal distribution.
 
{{header|Ada}}
Line 63 ⟶ 65:
 
{{header|E}}
 
accum [] for _ in 1..1000 { _.with(entropy.nextGaussian()) }
 
{{header|IDL}}
 
result = 1.0 + 0.5*randomn(seed,1000)
 
Line 85:
 
{{header|Pop11}}
 
;;; Choose radians as arguments to trigonometic functions
true -> popradians;
Line 109 ⟶ 108:
 
{{header|Tcl}}
 
proc nrand {} {return [expr sqrt(-2*log(rand()))*cos(4*acos(0)*rand())]}
for {set i 0} {$i < 1000} {incr i} {lappend result [expr 1+.5*nrand()]}
Anonymous user