To calculate the 99.99% confidence interval in Matlab, we can use the norminv
function which returns the value of the inverse cumulative distribution function (CDF) of a standard normal distribution. The formula to calculate the confidence interval is:
main.m84 chars2 lines
where mean
is the sample mean, sigma
is the sample standard deviation, n
is the sample size, and z
is the critical value of the standard normal distribution for the given confidence level.
For a 99.99% confidence level, z
can be calculated as:
main.m35 chars2 lines
Here, 1 + 0.9999
is divided by 2 because we are interested in the two-tailed test. The second and third arguments of the norminv
function correspond to the mean and standard deviation of the standard normal distribution, which are 0 and 1 respectively.
Putting it all together, we can write the following Matlab code to calculate the 99.99% confidence interval:
main.m394 chars16 lines
The confidence_interval
variable now contains the lower and upper limits of the 99.99% confidence interval.
gistlibby LogSnag