en ru

Docs

NAME

calcMeanCI - calculate confidence interval for the mean

SYNOPSIS

function calcMeanCI(mean, meansqr, times, beta);

DESCRIPTION

The function is used to calculate confidence interval for the mean of a random value. Calculation method does not require the data set itself, but it's two statistics: mean and meansqr. The first one stands for the arithmetic mean of the original sample, the second one - for the arithmetic mean of the squared sample. Another required value is the sample size, it is passed through the times parameter. Argument beta indicates the desired level of confidence.

RETURN VALUES

The result of calcMeanCI is a positive number delta. Using this number the confidence interval can be written in form (mean ± delta).

NOTES

Sample size must be large enough to make the central limit theorem applicable. Values of beta other then 0.95, 0.99, 0.999 are not supported and would lead to zero result.

EXAMPLES

A simple case:

-- Let the data set to be as follows;
x = {1.35, 1.34, 1.37, 1.36, 1.35, 1.40, 1.35, 1.37, 1.32, 1.34};

-- It's statistics can be estimated like that;
mean = 0.0;
meansqr = 0.0;
for i = 1, #x do
   mean = mean + x[i];
   meansqr = meansqr + x[i] * x[i];
   end

mean = mean / #x; -- 1.355
meansqr = meansqr / #x; -- 1.83645

-- To get the desired confidence interval simply call the function;
delta = calcMeanCI(mean, meansqr, #x, 0.95); -- 0.01347

SEE ALSO

Confidence interval for the mean

Verbatim copying and distribution of this entire article are permitted in any medium, provided this notice is preserved.
Send suggestions, questions and bug reports to neurowombatmail@gmail.com
Copyright © 2009, 2010, 2011, 2012 Andrew Timashov