Normal random number generator.

When used in a series expression, nrnd generates (pseudo) random draws from a normal distribution with zero mean and unit variance.

Examples

smpl @first @first

series y = 0

smpl @first+1 @last

series y = .6*y(-1)+.5*nrnd

generates a Y series that follows an AR(1) process with initial value zero. The innovations are normally distributed with mean zero and standard deviation 0.5.

series u = 10+@sqr(3)*nrnd

series z = u+.5*u(-1)

generates a Z series that follows an MA(1) process. The innovations are normally distributed with mean 10 and variance 3.

series x = nrnd^2+nrnd^2+nrnd^2

generates an X series as the sum of squares of three independent standard normal random variables, which has a distribution. Note that adding the sum of the three series is not the same as issuing the command:

series x=3*nrnd^2

since the latter involves the generation of a single random variable.

The command:

series x=@qchisq(rnd,3)

provides an alternative method of simulating random draws from a distribution.

Cross-references

See “Statistical Distribution Functions” for a list of other random number generating functions from various distributions.