i want to generate normally distributed random data matrices. Are there any java or related functions available for implementing this.
views:
161answers:
2
+3
A:
This is built into the standard libraries.
Use Random.nextGaussian()
defined here.
This returns a floating-point number for a normal distribution with mean 0.0
and standard deviation 1.0
.
If you need a random number from a distribution of mean m
and standard deviation s
, use this expression:
( Random.nextGaussian() * s ) + m
Jason Cohen
2009-03-09 17:36:03
In some of the runs of the program i got no.s above 1.0 when m =0; s =1;Any idea why this may happen?I use eclipse IDE for running the program.
BHARATH
2009-03-10 11:28:24
About 82% of the values should be less than 1.0. If you only generated a few numbers, your result is expected.
Jason Cohen
2009-03-10 20:49:21