*kf
by An Uncommon Lab

normalbounds

Return the boundaries containing 100% p points drawn from a normal distribution.

bounds = normalbounds(p)
bounds = normalbounds(p, mu)
bounds = normalbounds(p, mu, sigma)

Inputs

p

Fraction of data within bounds (e.g., 0.95 for 95%)

mu

Mean (defaults to 0)

sigma

Standard deviation (defaults to 1)

Outputs

bounds

Bounds containing p fraction of data

Example

We'll make sure that the theoretical and empircal bounds match up reasonably well for some random draws.

% Generate 10,000 samples from a normal distribution.
n     = 10000;
mu    = 1;
sigma = 3;
x     = sigma * randn(1, n) + mu;
 
% Get the theoretical 95% bounds.
b = normalbounds(0.95, mu, sigma);
 
% See what percentage of the data are within bounds.
sum(b(1) < x & x < b(2)) / n
ans =
    0.9477

See Also

chisqbounds

Table of Contents

  1. Inputs
  2. Outputs
  3. Example
  4. See Also