<< conint_bernoullipnumber Conint conint_normmunumber >>

Conint >> Conint > conint_normmu

conint_normmu

C.I. of the mean of a normal variable.

Calling Sequence

[ low, up ] = conint_normmu ( n , me , v )
[ low, up ] = conint_normmu ( n , me , v , level )
[ low, up ] = conint_normmu ( n , me , v , level , twosided )
[ low, up ] = conint_normmu ( n , me , v , level , twosided , known )

Parameters

n :

a n-by-1 or 1-by-n matrix of doubles, integer value, positive, the number of samples

me :

a 1-by-1 matrix of doubles, the mean estimate

level :

a 1-by-1 matrix of doubles, the confidence level (default level = 1.-0.95=0.05). level is expected to be in the range [0.,0.5]

v :

a 1-by-1 matrix of doubles, the variance. By default, the variance is assumed to be exact (i.e. by default known=%t). If the variance v is estimated, then set the known option to %f.

twosided :

a 1-by-1 matrix of booleans, the side of the interval (default twosided = %t). If twosided is %t, then low and up make a two-sided interval [low,up]. If twosided is %f, then the intervals are [-inf,up] and [low,inf].

known :

a 1-by-1 matrix of booleans, %t if the variance v is exact (default known = %t). If known is %t, then v is the exact variance. If known is %f, then v is the estimate of the variance.

low :

a 1-by-1 matrix of doubles, the estimated lower bound

up :

a 1-by-1 matrix of doubles, the estimated upper bound

Description

Computes a confidence interval of the mean of a normal variable, that is, computes m as the mean of x and computes confidence intervals for mu(X).

If twosided is true, then low and up are such that the expectation mu(X) is such that

P(low < mu(X) < up) = 1-level

If twosided is false, then low and up are such that the expectation mu is such that

P(mu(X) < up) = 1-level

and

P(low < mu(X)) = 1-level

This function makes the assumption that the data in x has a normal distribution with expectation mu(X) and variance var(X).

If the variance is exact (i.e. known=%t) then we use a Normal distribution to compute the confidence interval.

If the variance is estimated (i.e. if known=%f), then we use Student's T distribution to compute the confidence interval.

Examples

// Sheldon Ross, Example 7.3a, page 241
x = [5, 8.5, 12, 15, 7, 9, 7.5, 6.5, 10.5]
n = size(x,"*")
me = mean(x)
// By default, we compute a two-sided 95% C.I.
// with exact variance:
v = 4.
[ low, up ] = conint_normmu ( n , me , v )
low_expected = 7.69
up_expected = 10.31
// Then P(7.69 <= mu <= 10.31) = 0.95

// Get one-sided 95% C.I.
// Example 7.3b, p. 242
low_expected = 7.903
up_expected = 10.097
twosided = %f
[ low, up ] = conint_normmu ( n , me , v , [] , twosided )
// Then : P(7.903 <= mu) = 0.95
//       P(mu <= 10.097) = 0.95

// Example 7.3c, p. 244
// Two-sided 99% interval : (7.28, 10.72)
[ low, up ] = conint_normmu ( n , me , v , 1.-0.99 )
// One-sided 99% intervals : (7.447,inf), (−inf, 10.553)
[ low, up ] = conint_normmu ( n , me , v , 1.-0.99 , %f )

// EXAMPLE 7.3e, p. 247
// The variance is unknown: use Student's T random variable
v = variance(x)
[ low, up ] = conint_normmu ( n , me , v , [] , [] , %f )
// Then P(6.63<= mu <= 11.37) = 0.95

// EXAMPLE 7.3f, p.249
x = [54, 63, 58, 72, 49, 92, 70, 73, ..
69, 104, 48, 66, 80, 64, 77];
n = size(x,"*")
me = mean(x)
v = variance(x)
// Two-sided :
[ low, up ] = conint_normmu ( n , me , v , 1.-0.95 , [] , %f )
// Then P(60.865<= mu <=77.6683) = 0.95
// One-sided :
[ low, up ] = conint_normmu ( n , me , v , 1.-0.95 , %f , %f )
// Then : P (mu <= 76.16) = 0.95
// Then : P (62.368 <= mu) = 0.95

// EXAMPLE 7.3g, Monte-Carlo simulation
U = grand(100,1,"def");
x = sqrt(1-U.^2);
n = size(x,"*")
me = mean(x)
v = variance(x)
[ low, up ] = conint_normmu ( n , me , v , [] , [] , %f )
// Exact integral is :
%pi/4

Authors

Bibliography

http://en.wikipedia.org/wiki/Confidence_interval

"Introduction to probability and statistics for engineers and scientists", Sheldon Ross, Third Edition, 2004


Report an issue
<< conint_bernoullipnumber Conint conint_normmunumber >>