The randNorm() Command

randnorm.png

Command Summary

Generates a random normally-distributed number.

Command Syntax

randNorm(mean,std-dev)

Menu Location

  • Press 2nd MATH to enter the MATH popup menu.
  • Press 7 to enter the Probability submenu.
  • Press 5 to select randNorm(.

Calculator Compatibility

This command works on all calculators.

Token Size

1 byte

The randNorm() command generates a random number that is normally distributed, with a given mean (first parameter) and standard deviation (second parameter). This means that on average, randNorm(x,y) will give a result of about x; it's 95% certain to be within 2*y of x.

See rand() and RandSeed for more details on the random number generator.

Formula

The formula for randNorm() is different from the one used by the TI-83 series. To generate normally-distributed values from the output of rand(), the calculator uses the polar form of the Box-Muller transform. The algorithm goes as follows:

First, generate two uniformly distributed numbers u and v in [-1,1]. Keep doing this until the result lies in the unit circle; the point (0,0), though it's unlikely to occur, is discarded as well. Let s equal u2+v2.

Usually, Box-Muller is used to produce two normally-distributed random numbers, by the formula below. The TI only uses the second of the results:

(1)
\begin{align} z_0=u\cdot\sqrt{\frac{-2\ln s}{s}}\hspace{2em}z_1=v\cdot\sqrt{\frac{-2\ln s}{s}} \end{align}

The result is distributed according to the standard normal distribution: that is, with mean 0 and standard deviation 1. It's easy to get any other normal distribution by scaling: multiplying by the standard deviation, and then adding the mean.

In TI-Basic, the code for randNorm(μ,σ) would be:

:Loop
: 2*rand()-1→u
: 2*rand()-1→v
: u^2+v^2→s
: If 0<s and s<1
:  Return μ+σ*v*√(-2*ln(s)/s)
:EndLoop

Related Commands

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.