Java – random can be obtained from the distribution of different mean and standard deviation Nextgaussian() sample value?

This is a combination of Java and basic mathematical problems From random The documentation of nextgaussian () shows that it samples from the normal distribution of mean 0 and standard deviation 1 What if I want to sample from a normal distribution with different means and variances?

Solution

The short answer is

Random r = new Random();
double mySample = r.nextGaussian()*desiredStandardDeviation+desiredMean;

For example, the answer is given here: http://www.javamex.com/tutorials/random_numbers/gaussian_distribution_2.shtml

I really don't understand why this job is, but after looking at it, I think I can figure it out The average value of sampling points is 0 and the standard deviation is 1; This means that the original sample is also its own Z-score( https://en.wikipedia.org/wiki/Standard_score ). quoted from Wikipedia "the absolute value of Z represents the distance between the original score and the overall average, and the unit is standard deviation" The formula is Z = (x-mean) / STDev, so the default value is Z = X. what should we do if we want to keep the Z-score of the sample, but change the average and STDev?

Z * STDev mean = x 'where z = x, X' represents the sample with the distribution of the required mean and standard deviation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>