NSoft.NFramework.Numerics.Distributions.Continuous.Normal.Sample C# (CSharp) Method

Sample() public static method

Generates a sample from the normal distribution using the Box-Muller algorithm.
public static Sample ( Random rnd, double mean, double stDev ) : double
rnd System.Random The random number generator to use.
mean double The mean of the normal distribution from which to generate samples.
stDev double The standard deviation of the normal distribution from which to generate samples.
return double
        public static double Sample(Random rnd, double mean, double stDev) {
            AssertParameters(mean, stDev);

            return mean + (stDev * SampleBoxMuller(rnd).Item1);
        }

Same methods

Normal::Sample ( ) : double

Usage Example

Beispiel #1
0
        public void StaticSampleTest()
        {
            Normal.Sample(new Random(), 0.0, 1.0).Should().Not.Be(double.NaN);

            Assert.Throws <InvalidOperationException>(() => Normal.Sample(new Random(), 0.0, -1.0));
        }