tags:

views:

161

answers:

2

i want to generate normally distributed random data matrices. Are there any java or related functions available for implementing this.

+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
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
About 82% of the values should be less than 1.0. If you only generated a few numbers, your result is expected.
Jason Cohen
+2  A: 

Have a look at Uncommons Maths - it should be able to help.

Rich
i got a look at uncommon mathit is not particularly concerned with java.i was looking for a module or function for producing uniformly distributed no.s.
BHARATH
Uncommons Maths is uniquely concerned with Java
Rich