BHS
BHS

Reputation: 1021

any functions available in java or related libraries for generating random data in normal distribution

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

Upvotes: 1

Views: 713

Answers (2)

Rich
Rich

Reputation: 15767

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

Upvotes: 3

Jason Cohen
Jason Cohen

Reputation: 83021

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

Upvotes: 3

Related Questions