Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private double getNormalDistributed(double? mean, double? standardDev)
- {
- //This has to happen here since mean and standard deviation can be different for each call, and those values are readonly in the Normal
- MathNet.Numerics.Distributions.Normal normalDistribution = new MathNet.Numerics.Distributions.Normal((double)mean, (double)standardDev, random);
- double result = normalDistribution.Sample();
- //Force the result to be not more than 2 standard deviations away from the mean
- if (result > mean + 2 * standardDev) result = (double)mean + 2 * (double)standardDev;
- if (result < mean - 2 * standardDev) result = (double)mean - 2 * (double)standardDev;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement