en ru

Docs

NAME

calcACProbabilityCI - calculate confidence interval for the probability

SYNOPSIS

function calcACProbabilityCI(p, times, alpha);

DESCRIPTION

The function is used to calculate the Agresti-Coull confidence interval for probability estimate p obtained in times trials. Argument alpha indicates the desired significance level.

RETURN VALUES

calcACProbabilityCI returns two numbers: the beginning and end of the confidence interval.

NOTES

Values of alpha other then 0.05, 0.01, 0.001 are not supported and would lead to empty confidence interval around p.

EXAMPLES

A simple case:

-- Let the random variable x has the following values;
x = {1.35, 1.34, 1.37, 1.36, 1.35, 1.40, 1.35, 1.37, 1.32, 1.34};

-- The probability of x > 1.34 can be estimated like that;
p = 0.0;
for i = 1, #x do
   if x[i] > 1.34 then p = p + 1.0 end
   end

p = p / #x; -- 0.7

-- To get the desired confidence interval simply call the function;
pMin, pMax = calcACProbabilityCI(p, #x, 0.05); -- 0.392, 0.897

SEE ALSO

Confidence interval for the probability

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