Normal Distribution

Set up

<< Statistics`

?Norm*

The "p" in NormalPValue gives the area under the standard normal curve, but it goes to the left or right depending on whether z is negative or positive.

?NormalPValue

Plot[OneSidedPValue /. NormalPValue[x], {x, -3, 3},  
      PlotRange -> All]

The left side of the previous figure is the same as this "CDF" ( CumulativeDistributionFunction ).

Plot[CDF[NormalDistribution[0, 1], x], {x, -4, 4}]

Normal distribution

Here's how we get the normal probability distribution function.

Plot[PDF[NormalDistribution[0, 1], x], {x, -3, 3}]

The following definition returns the area (Cumulative Distribution Function) of the "standard normal distribution", i.e. a Gaussian with μ=0 and σ=1.  These are the numbers in table D-4 in the Understanding Statistics text, which is the probability for a value at or below the given z.

prob[z_] := CDF[NormalDistribution[0, 1], z];

Plot[prob[z], {z, -3, 3}]

prob[-2.58]

Since this is in the z<0 range, its the same as the NormalPValue result.

NormalPValue[-2.58]

But on the positive side we have

prob[2. ]

NormalPValue[2. ]

1  -  OneSidedPValue /. NormalPValue[2]

To find the inverse function, Mathematica uses the Quantile property of a distribution, which returns the z value where the distribution accumulates a given total probability.  So to find out the z value such that the probability below that z is 0.9775, we do this.

quan[p_] := Quantile[NormalDistribution[0, 1], p]

quan[0.97725]

Plot[quan[p], {p, 0, 1}]

Mathematica Summary

Normal distribution probabilities from z-scores.

<< Statistics`;
prob[z_] := 
        CDF[NormalDistribution[0, 1], z];
quan[p_] := Quantile[NormalDistribution[0, 1], p];

Table D-4 in the text says that the probability for z ≤ -2.58 is 0.0049.  You get those numbers with these functions like this:

prob[-2.58]

quan[0.0049]

Using the Error Function (Erf) Instead

These areas can also be found by using the "Error Function" or "Erf", which is the area starting at z=0 when σ = 1/(Sqrt[2]).
(Internally this is what Mathematica does, treating Erf[x] as a built-in like Sin[x].)
So the integral of the standard normal distribution from 0 to z is also given by 0.5 Erf[z/(Sqrt[2])].
For example, here is the area under the normal curve from z=0 to z=1, calculated to 20 places, two ways.

N[(areaLeftZNormal[1] - areaLeftZNormal[0]), 20]

N[Erf[1/(Sqrt[2])]/2, 20]

Or, going the other way

N[Erf[1], 20]

N[2 (CDF[NormalDistribution[0, 1/(Sqrt[2])], 1] - 1/2), 20]

Mathematica also defines Erfc[z] = 1 - Erf[z] (Erf complement) which gives us another way to define f[z] = areaLeftOfZNormal[z].

f[z_] := Erfc[-z/(Sqrt[2])]/2

Plot[f[z], {z, -3, 3}]

Inverting this gives

p = f[z] = Erfc[-z/(Sqrt[2])]/2  ,   where 0 ≤ 
      p ≤ 1,  
    and  - ∞ ≤ 
      z ≤ ∞ 
z = fInv[p]  =  -(Sqrt[2]) InverseErfc[2  p]

fInv[p_] := -(Sqrt[2]) InverseErfc[2  p]

Plot[fInv[p], {p, 0, 1}]

So the total probability under the standard (μ=0,σ=1) Normal curve, for z ≤ 1 is

f[1. ]

And the value of z for which the probability is 0.841345 is

fInv[0.841345]

Excel, TI-83

In Excel, these functions are
  probability = NORMSDIST(z)  -  cumulative standard normal distribution, 0 ≤ p ≤ 1 for -∞ ≤ z ≤ ∞ , μ=0, σ=1.
  probability = NORMDIST(x, mean, standard_deviation, cumulative),  where cumulative is TRUE or FALSE.
  
  z = NORMSINV(proability) is the inverse function of NORMSDIST.
  x = NORMINV(probability,mean,standard_deviation)  is the inverse of NORMDIST with cumulative=TRUE.

On the TI-83, the functions are 
    normalcdf(left,right,[mu,sigma]) finds the area under the normal curve (This function is listed under the "Distru" menu.)
    invNorm(prob,[mu,sigma]) 
    
    This means that what I was calling prob[z] and is listed in Table D-4 is normalcdf(-1e99,z).