This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Add-ons / Standard Packages / Statistics  /


A confidence interval gives a bound within which a parameter is expected to lie with a certain probability. Interval estimation of a parameter is often useful in observing the accuracy of an estimator as well as in making statistical inferences about the parameter in question. With this package, you can find confidence intervals for various parameters such as means, differences between two population means, variances and ratios of the variance of two populations. The functions in this package calculate sample estimates and return bounds for intervals using the specified confidence level. The confidence intervals computed in this package assume that the univariate data are normally distributed.

Confidence interval for the mean.

A confidence interval for the mean of a distribution is centered at and has a half length proportional to the standard deviation of the estimator. If the variance of the underlying distribution is known, and given by the option KnownVariance

->var, then the interval is calculated using the appropriate quantile of the standard normal distribution. The resulting interval is , where is (1

+ConfidenceLevel)/2 and

If the variance is unknown, the standard deviation must be estimated, and the confidence interval takes the form , where is the

quantile of the Student distribution and is the standard error of the mean. The confidence level used in computing the interval is specified by the option ConfidenceLevel, which has a default value of


  • This loads the package.
  • In[1]:= <<Statistics`ConfidenceIntervals`

  • Here is a list of sample values. The data are assumed to be a random sample from the normally distributed population with unknown variance.
  • In[2]:= data1 = {2.1, 1.2, 0.7, 1.0, 1.1, 3.2, 3.2,
    3.3, 2.1, 0.3};

  • The confidence bounds that are computed are based on the Student distribution with confidence level

  • In[3]:= MeanCI[data1]


    Option for all confidence interval functions.

    You can calculate confidence intervals for the difference in means of two populations using MeanDifferenceCI.

    Confidence intervals for difference in means.

    If variances are unknown, you can specify that the population variances are equal with EqualVariances->True. In this case the Student distribution is used with degrees of freedom, where and are the sample sizes from the first and the second populations, respectively. If the unknown variances are not specified as equal, a more conservative interval is computed using Welch's approximate


  • Here is a second list of sample values from a population whose variance is unknown.
  • In[4]:= data2 = {1.8, 0.2, 1.5, 1.9, 1.1, 3.0, 2.3,
    0.9, 2.4, 1.0};

  • This is the interval for the difference in the two means, assuming equal variances.
  • In[5]:= MeanDifferenceCI[data1, data2,
    EqualVariances -> True]


  • If equal variances cannot be assumed, the computed interval is larger, or more conservative.
  • In[6]:= MeanDifferenceCI[data1, data2]


    Options for the confidence interval for difference in means.

    You can also compute intervals for population variance and ratio of population variances. The bounds for these intervals are determined by the sample standard deviations and the appropriate quantiles from the chi-square or the -ratio distributions. Note that the ConfidenceLevel

    option is available for all confidence interval functions provided in this package.

    Confidence intervals for variances.

  • Here is the interval for the population variance of the first sample.
  • In[7]:= VarianceCI[data1]


  • This gives the

    percent confidence interval for the ratio of two variances whose populations are represented by the two samples.
  • In[8]:= VarianceRatioCI[data1, data2,
    ConfidenceLevel -> .9]


    The package also provides functions for calculating confidence intervals from derived statistics rather than sample data. This may be useful when parameter estimates are available, in which case you do not have to input any data. You can use functions from the Statistics`DescriptiveStatistics` package to get the necessary derived statistics of your sample data. This package is automatically loaded when you load Statistics`ConfidenceIntervals`.

    Confidence intervals given sample estimates.

  • This calculates the mean of the sample data that were given at the beginning of this section.
  • In[9]:= mean = Mean[data1]


  • This estimates the standard error of the mean using a function from the package Statistics`DescriptiveStatistics` which is automatically loaded with this one.
  • In[10]:= se = StandardErrorOfSampleMean[data1]


  • The same interval is computed using the estimated standard error as was found by using MeanCI above.
  • In[11]:= StudentTCI[mean, se, Length[data1] - 1,
    ConfidenceLevel -> 0.9]