Reputation: 1021
i want to generate normally distributed random data matrices. Are there any java or related functions available for implementing this.
Upvotes: 1
Views: 713
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