normrnd
Random samples from a normal distribution with mean mu and standard deviation sigma.
Syntax
Section titled “Syntax”r = normrnd(mu, sigma)r = normrnd(mu, sigma, n)r = normrnd(mu, sigma, m, n, ...)Description
Section titled “Description”Returns pseudorandom values from the normal distribution N(mu, sigma²). With two arguments, returns a single scalar. With additional dimension arguments, returns an array of the requested shape.
Uses a fresh std::random_device-seeded Mersenne Twister generator on each call — this is independent of the PRNG state used by rand, randn, etc. (so calls don’t disturb the main RNG sequence).
For parameter-free standard normal samples that share the main RNG state, use randn.
Examples
Section titled “Examples”normrnd(100, 15) % single sample from N(100, 225)normrnd(0, 1, 1000, 1) % 1000 standard-normal samplesnormrnd(5, 2, 3, 3) % 3×3 from N(5, 4)