Normal distributions are important in
statistics and are often used in the
natural and
social sciences to represent real-valued
random variables whose distributions are not known.[2][3] Their importance is partly due to the
central limit theorem. It states that, under some conditions, the average of many samples (observations) of a random variable with finite mean and variance is itself a random variable—whose distribution
converges to a normal distribution as the number of samples increases. Therefore, physical quantities that are expected to be the sum of many independent processes, such as
measurement errors, often have distributions that are nearly normal.[4]
Moreover, Gaussian distributions have some unique properties that are valuable in analytic studies. For instance, any
linear combination of a fixed collection of independent normal deviates is a normal deviate. Many results and methods, such as
propagation of uncertainty and
least squares[5] parameter fitting, can be derived analytically in explicit form when the relevant variables are normally distributed.
A normal distribution is sometimes informally called a bell curve.[6] However, many other distributions are
bell-shaped (such as the
Cauchy,
Student's t, and
logistic distributions). (For other names, see Naming.)
The simplest case of a normal distribution is known as the standard normal distribution or unit normal distribution. This is a special case when and , and it is described by this
probability density function (or density):
The variable has a mean of 0 and a variance and standard deviation of 1. The density has its peak at and
inflection points at and .
Although the density above is most commonly known as the standard normal, a few authors have used that term to describe other versions of the normal distribution.
Carl Friedrich Gauss, for example, once defined the standard normal as
which has a variance of , and
Stephen Stigler[7] once defined the standard normal as
which has a simple functional form and a variance of
General normal distribution
Every normal distribution is a version of the standard normal distribution, whose domain has been stretched by a factor (the standard deviation) and then translated by (the mean value):
The probability density must be scaled by so that the
integral is still 1.
If is a
standard normal deviate, then will have a normal distribution with expected value and standard deviation . This is equivalent to saying that the standard normal distribution can be scaled/stretched by a factor of and shifted by to yield a different normal distribution, called . Conversely, if is a normal deviate with parameters and , then this distribution can be re-scaled and shifted via the formula to convert it to the standard normal distribution. This variate is also called the standardized form of .
Notation
The probability density of the standard Gaussian distribution (standard normal distribution, with zero mean and unit variance) is often denoted with the Greek letter (
phi).[8] The alternative form of the Greek letter phi, , is also used quite often.
The normal distribution is often referred to as or .[9] Thus when a random variable is normally distributed with mean and standard deviation , one may write
Alternative parameterizations
Some authors advocate using the
precision as the parameter defining the width of the distribution, instead of the standard deviation or the variance . The precision is normally defined as the reciprocal of the variance, .[10] The formula for the distribution then becomes
This choice is claimed to have advantages in numerical computations when is very close to zero, and simplifies formulas in some contexts, such as in the
Bayesian inference of variables with
multivariate normal distribution.
Alternatively, the reciprocal of the standard deviation might be defined as the precision, in which case the expression of the normal distribution becomes
According to Stigler, this formulation is advantageous because of a much simpler and easier-to-remember formula, and simple approximate formulas for the
quantiles of the distribution.
Normal distributions form an
exponential family with
natural parameters and , and natural statistics x and x2. The dual expectation parameters for normal distribution are η1 = μ and η2 = μ2 + σ2.
Cumulative distribution function
The
cumulative distribution function (CDF) of the standard normal distribution, usually denoted with the capital Greek letter , is the integral
Error function
The related
error function gives the probability of a random variable, with normal distribution of mean 0 and variance 1/2 falling in the range . That is:
These integrals cannot be expressed in terms of elementary functions, and are often said to be
special functions. However, many numerical approximations are known; see
below for more.
The two functions are closely related, namely
For a generic normal distribution with density , mean and variance , the cumulative distribution function is
The complement of the standard normal cumulative distribution function, , is often called the
Q-function, especially in engineering texts.[11][12] It gives the probability that the value of a standard normal random variable will exceed : . Other definitions of the -function, all of which are simple transformations of , are also used occasionally.[13]
The
graph of the standard normal cumulative distribution function has 2-fold
rotational symmetry around the point (0,1/2); that is, . Its
antiderivative (indefinite integral) can be expressed as follows:
The cumulative distribution function of the standard normal distribution can be expanded by
Integration by parts into a series:
A quick approximation to the standard normal distribution's cumulative distribution function can be found by using a Taylor series approximation:
Recursive computation with Taylor series expansion
The recursive nature of the family of derivatives may be used to easily construct a rapidly converging
Taylor series expansion using recursive entries about any point of known value of the distribution,:
where:
Using the Taylor series and Newton's method for the inverse function
An application for the above
Taylor series expansion is to use
Newton's method to reverse the computation. That is, if we have a value for the
cumulative distribution function, , but do not know the x needed to obtain the , we can use Newton's method to find x, and use the Taylor series expansion above to minimize the number of computations. Newton's method is ideal to solve this problem because the first derivative of , which is an integral of the normal standard distribution, is the normal standard distribution, and is readily available to use in the Newton's method solution.
To solve, select a known approximate solution, , to the desired . may be a value from a distribution table, or an intelligent estimate followed by a computation of using any desired means to compute. Use this value of and the Taylor series expansion above to minimize computations.
Repeat the following process until the difference between the computed and the desired , which we will call , is below a chosen acceptably small error, such as 10−5, 10−15, etc.:
where
is the from a Taylor series solution using and
When the repeated computations converge to an error below the chosen acceptably small value, x will be the value needed to obtain a of the desired value, .
About 68% of values drawn from a normal distribution are within one standard deviation σ from the mean; about 95% of the values lie within two standard deviations; and about 99.7% are within three standard deviations.[6] This fact is known as the
68–95–99.7 (empirical) rule, or the 3-sigma rule.
More precisely, the probability that a normal deviate lies in the range between and is given by
To 12 significant digits, the values for are:
The
quantile function of a distribution is the inverse of the cumulative distribution function. The quantile function of the standard normal distribution is called the
probit function, and can be expressed in terms of the inverse
error function:
For a normal random variable with mean and variance , the quantile function is
The
quantile of the standard normal distribution is commonly denoted as . These values are used in
hypothesis testing, construction of
confidence intervals and
Q–Q plots. A normal random variable will exceed with probability , and will lie outside the interval with probability . In particular, the quantile is
1.96; therefore a normal random variable will lie outside the interval in only 5% of cases.
The following table gives the quantile such that will lie in the range with a specified probability . These values are useful to determine
tolerance interval for
sample averages and other statistical
estimators with normal (or
asymptotically normal) distributions.[15] The following table shows , not as defined above.
The normal distribution is the only distribution whose
cumulants beyond the first two (i.e., other than the mean and
variance) are zero. It is also the continuous distribution with the
maximum entropy for a specified mean and variance.[16][17] Geary has shown, assuming that the mean and variance are finite, that the normal distribution is the only distribution where the mean and variance calculated from a set of independent draws are independent of each other.[18][19]
The normal distribution is a subclass of the
elliptical distributions. The normal distribution is
symmetric about its mean, and is non-zero over the entire real line. As such it may not be a suitable model for variables that are inherently positive or strongly skewed, such as the
weight of a person or the price of a
share. Such variables may be better described by other distributions, such as the
log-normal distribution or the
Pareto distribution.
The value of the normal density is practically zero when the value lies more than a few
standard deviations away from the mean (e.g., a spread of three standard deviations covers all but 0.27% of the total distribution). Therefore, it may not be an appropriate model when one expects a significant fraction of
outliers—values that lie many standard deviations away from the mean—and least squares and other
statistical inference methods that are optimal for normally distributed variables often become highly unreliable when applied to such data. In those cases, a more
heavy-tailed distribution should be assumed and the appropriate
robust statistical inference methods applied.
The Gaussian distribution belongs to the family of
stable distributions which are the attractors of sums of
independent, identically distributed distributions whether or not the mean or variance is finite. Except for the Gaussian which is a limiting case, all stable distributions have heavy tails and infinite variance. It is one of the few distributions that are stable and that have probability density functions that can be expressed analytically, the others being the
Cauchy distribution and the
Lévy distribution.
Symmetries and derivatives
The normal distribution with density (mean and variance ) has the following properties:
It is symmetric around the point which is at the same time the
mode, the
median and the
mean of the distribution.[20]
It is
unimodal: its first
derivative is positive for negative for and zero only at
The area bounded by the curve and the -axis is unity (i.e. equal to one).
Its first derivative is
Its second derivative is
Its density has two
inflection points (where the second derivative of is zero and changes sign), located one standard deviation away from the mean, namely at and [20]
Furthermore, the density of the standard normal distribution (i.e. and ) also has the following properties:
Its first derivative is
Its second derivative is
More generally, its nth derivative is where is the nth (probabilist)
Hermite polynomial.[22]
The probability that a normally distributed variable with known and is in a particular set, can be calculated by using the fact that the fraction has a standard normal distribution.
The plain and absolute
moments of a variable are the expected values of and , respectively. If the expected value of is zero, these parameters are called central moments; otherwise, these parameters are called non-central moments. Usually we are interested only in moments with integer order .
If has a normal distribution, the non-central moments exist and are finite for any whose real part is greater than −1. For any non-negative integer , the plain central moments are:[23]
Here denotes the
double factorial, that is, the product of all numbers from to 1 that have the same parity as
The central absolute moments coincide with plain moments for all even orders, but are nonzero for odd orders. For any non-negative integer
The last formula is valid also for any non-integer When the mean the plain and absolute moments can be expressed in terms of
confluent hypergeometric functions and [24]
The expectation of conditioned on the event that lies in an interval is given by
where and respectively are the density and the cumulative distribution function of . For this is known as the
inverse Mills ratio. Note that above, density of is used instead of standard normal density as in inverse Mills ratio, so here we have instead of .
where is the
imaginary unit. If the mean , the first factor is 1, and the Fourier transform is, apart from a constant factor, a normal density on the
frequency domain, with mean 0 and variance . In particular, the standard normal distribution is an
eigenfunction of the Fourier transform.
In probability theory, the Fourier transform of the probability distribution of a real-valued random variable is closely connected to the
characteristic function of that variable, which is defined as the
expected value of , as a function of the real variable (the
frequency parameter of the Fourier transform). This definition can be analytically extended to a complex-value variable .[26] The relation between both is:
Moment- and cumulant-generating functions
The
moment generating function of a real random variable is the expected value of , as a function of the real parameter . For a normal distribution with density , mean and variance , the moment generating function exists and is equal to
For any , the coefficient of in the moment generating function (expressed as an
exponential power series in ) is the normal distribution's expected value .
The coefficients of this exponential power series define the cumulants, but because this is a quadratic polynomial in , only the first two
cumulants are nonzero, namely the mean and the variance .
Some authors prefer to instead work with the
characteristic functionE[eitX] = eiμt − σ2t2/2 and ln E[eitX] = iμt − 1/2σ2t2.
Stein operator and class
Within
Stein's method the Stein operator and class of a random variable are and the class of all absolutely continuous functions .
Zero-variance limit
In the
limit when tends to zero, the probability density eventually tends to zero at any , but grows without limit if , while its integral remains equal to 1. Therefore, the normal distribution cannot be defined as an ordinary
function when .
However, one can define the normal distribution with zero variance as a
generalized function; specifically, as a
Dirac delta function translated by the mean , that is
Its cumulative distribution function is then the
Heaviside step function translated by the mean , namely
where is understood to be zero whenever . This functional can be maximized, subject to the constraints that the distribution is properly normalized and has a specified mean and variance, by using
variational calculus. A function with three
Lagrange multipliers is defined:
At maximum entropy, a small variation about will produce a variation about which is equal to 0:
Since this must hold for any small , the factor multiplying must be zero, and solving for yields:
The Lagrange constraints that is properly normalized and has the specified mean and variance are satisfied if and only if , , and are chosen so that
The entropy of a normal distribution is equal to
which is independent of the mean .
Other properties
If the characteristic function of some random variable is of the form in a neighborhood of zero, where is a
polynomial, then the Marcinkiewicz theorem (named after
Józef Marcinkiewicz) asserts that can be at most a quadratic polynomial, and therefore is a normal random variable.[31] The consequence of this result is that the normal distribution is the only distribution with a finite number (two) of non-zero
cumulants.
If and are
jointly normal and
uncorrelated, then they are
independent. The requirement that and should be jointly normal is essential; without it the property does not hold.[32][33][proof] For non-normal random variables uncorrelatedness does not imply independence.
The
conjugate prior of the mean of a normal distribution is another normal distribution.[35] Specifically, if are iid and the prior is , then the posterior distribution for the estimator of will be
The family of normal distributions not only forms an
exponential family (EF), but in fact forms a
natural exponential family (NEF) with quadratic
variance function (
NEF-QVF). Many properties of normal distributions generalize to properties of NEF-QVF distributions, NEF distributions, or EF distributions generally. NEF-QVF distributions comprises 6 families, including Poisson, Gamma, binomial, and negative binomial distributions, while many of the common families studied in probability and statistics are NEF or EF.
The central limit theorem states that under certain (fairly common) conditions, the sum of many random variables will have an approximately normal distribution. More specifically, where are
independent and identically distributed random variables with the same arbitrary distribution, zero mean, and variance and is their
mean scaled by
Then, as increases, the probability distribution of will tend to the normal distribution with zero mean and variance .
The theorem can be extended to variables that are not independent and/or not identically distributed if certain constraints are placed on the degree of dependence and the moments of the distributions.
Many
test statistics,
scores, and
estimators encountered in practice contain sums of certain random variables in them, and even more estimators can be represented as sums of random variables through the use of
influence functions. The central limit theorem implies that those statistical parameters will have asymptotically normal distributions.
The central limit theorem also implies that certain distributions can be approximated by the normal distribution, for example:
Whether these approximations are sufficiently accurate depends on the purpose for which they are needed, and the rate of convergence to the normal distribution. It is typically the case that such approximations are less accurate in the tails of the distribution.
A general upper bound for the approximation error in the central limit theorem is given by the
Berry–Esseen theorem, improvements of the approximation are given by the
Edgeworth expansions.
This theorem can also be used to justify modeling the sum of many uniform noise sources as
Gaussian noise. See
AWGN.
If is distributed normally with mean and variance , then
, for any real numbers and , is also normally distributed, with mean and variance . That is, the family of normal distributions is closed under
linear transformations.
The log-likelihood of a normal variable is simply the log of its
probability density function: Since this is a scaled and shifted square of a standard normal variable, it is distributed as a scaled and shifted
chi-squared variable.
If and are two
independent normal random variables, with means , and variances , , then their sum will also be normally distributed,[proof] with mean and variance .
In particular, if and are independent normal deviates with zero mean and variance , then and are also independent and normally distributed, with zero mean and variance . This is a special case of the
polarization identity.[40]
If , are two independent normal deviates with mean and variance , and , are arbitrary real numbers, then the variable is also normally distributed with mean and variance . It follows that the normal distribution is
stable (with exponent ).
If , are normal distributions, then their normalized
geometric mean is a normal distribution with and (see
here for a visualization).
Operations on two independent standard normal variables
If and are two independent standard normal random variables with mean 0 and variance 1, then
Their sum and difference is distributed normally with mean zero and variance two: .
If , are independent standard normal random variables, then the ratio of their normalized sums of squares will have the F-distribution with (n, m) degrees of freedom:[44]
Operations on multiple correlated normal variables
A
quadratic form of a normal vector, i.e. a quadratic function of multiple independent or correlated normal variables, is a
generalized chi-square variable.
Operations on the density function
The
split normal distribution is most directly defined in terms of joining scaled sections of the density functions of different normal distributions and rescaling the density to integrate to one. The
truncated normal distribution results from rescaling a section of a single density function.
Infinite divisibility and Cramér's theorem
For any positive integer , any normal distribution with mean and variance is the distribution of the sum of independent normal deviates, each with mean and variance . This property is called
infinite divisibility.[45]
Conversely, if and are independent random variables and their sum has a normal distribution, then both and must be normal deviates.[46]
This result is known as
Cramér's decomposition theorem, and is equivalent to saying that the
convolution of two distributions is normal if and only if both are normal. Cramér's theorem implies that a linear combination of independent non-Gaussian variables will never have an exactly normal distribution, although it may approach it arbitrarily closely.[31]
The Kac–Bernstein theorem
The
Kac–Bernstein theorem states that if and are independent and and are also independent, then both X and Y must necessarily have normal distributions.[47][48]
More generally, if are independent random variables, then two distinct linear combinations and will be independent if and only if all are normal and , where denotes the variance of .[47]
Extensions
The notion of normal distribution, being one of the most important distributions in probability theory, has been extended far beyond the standard framework of the univariate (that is one-dimensional) case (Case 1). All these extensions are also called normal or Gaussian laws, so a certain ambiguity in names exists.
The
multivariate normal distribution describes the Gaussian law in the k-dimensional
Euclidean space. A vector X ∈ Rk is multivariate-normally distributed if any linear combination of its components Σk j=1aj Xj has a (univariate) normal distribution. The variance of X is a k×k symmetric positive-definite matrix V. The multivariate normal distribution is a special case of the
elliptical distributions. As such, its iso-density loci in the k = 2 case are
ellipses and in the case of arbitrary k are
ellipsoids.
Complex normal distribution deals with the complex normal vectors. A complex vector X ∈ Ck is said to be normal if both its real and imaginary components jointly possess a 2k-dimensional multivariate normal distribution. The variance-covariance structure of X is described by two matrices: the variance matrix Γ, and the relation matrix C.
Gaussian processes are the normally distributed
stochastic processes. These can be viewed as elements of some infinite-dimensional
Hilbert spaceH, and thus are the analogues of multivariate normal vectors for the case k = ∞. A random element h ∈ H is said to be normal if for any constant a ∈ H the
scalar product(a, h) has a (univariate) normal distribution. The variance structure of such Gaussian random element can be described in terms of the linear covariance operator K: H → H. Several Gaussian processes became popular enough to have their own names:
A random variable X has a two-piece normal distribution if it has a distribution
where μ is the mean and σ12 and σ22 are the variances of the distribution to the left and right of the mean respectively.
The mean, variance and third central moment of this distribution have been determined[49]
where E(X), V(X) and T(X) are the mean, variance, and third central moment respectively.
One of the main practical uses of the Gaussian law is to model the empirical distributions of many different random variables encountered in practice. In such case a possible extension would be a richer family of distributions, having more than two parameters and therefore being able to fit the empirical distribution more accurately. The examples of such extensions are:
Pearson distribution — a four-parameter family of probability distributions that extend the normal law to include different skewness and kurtosis values.
The
generalized normal distribution, also known as the exponential power distribution, allows for distribution tails with thicker or thinner asymptotic behaviors.
It is often the case that we do not know the parameters of the normal distribution, but instead want to
estimate them. That is, having a sample from a normal population we would like to learn the approximate values of parameters and . The standard approach to this problem is the
maximum likelihood method, which requires maximization of the log-likelihood function:
Taking derivatives with respect to and and solving the resulting system of first order conditions yields the maximum likelihood estimates:
Estimator is called the sample mean, since it is the arithmetic mean of all observations. The statistic is
complete and
sufficient for , and therefore by the
Lehmann–Scheffé theorem, is the
uniformly minimum variance unbiased (UMVU) estimator.[50] In finite samples it is distributed normally:
The variance of this estimator is equal to the μμ-element of the inverse
Fisher information matrix. This implies that the estimator is
finite-sample efficient. Of practical importance is the fact that the
standard error of is proportional to , that is, if one wishes to decrease the standard error by a factor of 10, one must increase the number of points in the sample by a factor of 100. This fact is widely used in determining sample sizes for opinion polls and the number of trials in
Monte Carlo simulations.
The estimator is called the sample variance, since it is the variance of the sample (). In practice, another estimator is often used instead of the . This other estimator is denoted , and is also called the sample variance, which represents a certain ambiguity in terminology; its square root is called the sample standard deviation. The estimator differs from by having (n − 1) instead of n in the denominator (the so-called
Bessel's correction):
The difference between and becomes negligibly small for large n's. In finite samples however, the motivation behind the use of is that it is an
unbiased estimator of the underlying parameter , whereas is biased. Also, by the Lehmann–Scheffé theorem the estimator is uniformly minimum variance unbiased (
UMVU),[50] which makes it the "best" estimator among all unbiased ones. However it can be shown that the biased estimator is better than the in terms of the
mean squared error (MSE) criterion. In finite samples both and have scaled
chi-squared distribution with (n − 1) degrees of freedom:
The first of these expressions shows that the variance of is equal to , which is slightly greater than the σσ-element of the inverse Fisher information matrix . Thus, is not an efficient estimator for , and moreover, since is UMVU, we can conclude that the finite-sample efficient estimator for does not exist.
Applying the asymptotic theory, both estimators and are consistent, that is they converge in probability to as the sample size . The two estimators are also both asymptotically normal:
In particular, both estimators are asymptotically efficient for .
By
Cochran's theorem, for normal distributions the sample mean and the sample variance s2 are
independent, which means there can be no gain in considering their
joint distribution. There is also a converse theorem: if in a sample the sample mean and sample variance are independent, then the sample must have come from the normal distribution. The independence between and s can be employed to construct the so-called t-statistic:
This quantity t has the
Student's t-distribution with (n − 1) degrees of freedom, and it is an
ancillary statistic (independent of the value of the parameters). Inverting the distribution of this t-statistics will allow us to construct the
confidence interval for μ;[51] similarly, inverting the χ2 distribution of the statistic s2 will give us the confidence interval for σ2:[52]
where tk,p and χ2 k,p are the pth
quantiles of the t- and χ2-distributions respectively. These confidence intervals are of the confidence level1 − α, meaning that the true values μ and σ2 fall outside of these intervals with probability (or
significance level) α. In practice people usually take α = 5%, resulting in the 95% confidence intervals. The confidence interval for σ can be found by taking the square root of the interval bounds for σ2.
Approximate formulas can be derived from the asymptotic distributions of and s2:
The approximate formulas become valid for large values of n, and are more convenient for the manual calculation since the standard normal quantiles zα/2 do not depend on n. In particular, the most popular value of α = 5%, results in |z0.025| =
1.96.
Normality tests assess the likelihood that the given data set {x1, ..., xn} comes from a normal distribution. Typically the
null hypothesisH0 is that the observations are distributed normally with unspecified mean μ and variance σ2, versus the alternative Ha that the distribution is arbitrary. Many tests (over 40) have been devised for this problem. The more prominent of them are outlined below:
Diagnostic plots are more intuitively appealing but subjective at the same time, as they rely on informal human judgement to accept or reject the null hypothesis.
Q–Q plot, also known as
normal probability plot or
rankit plot—is a plot of the sorted values from the data set against the expected values of the corresponding quantiles from the standard normal distribution. That is, it is a plot of point of the form (Φ−1(pk), x(k)), where plotting points pk are equal to pk = (k − α)/(n + 1 − 2α) and α is an adjustment constant, which can be anything between 0 and 1. If the null hypothesis is true, the plotted points should approximately lie on a straight line.
P–P plot – similar to the Q–Q plot, but used much less frequently. This method consists of plotting the points (Φ(z(k)), pk), where . For normally distributed data this plot should lie on a 45° line between (0, 0) and (1, 1).
Shapiro–Wilk test: This is based on the fact that the line in the Q–Q plot has the slope of σ. The test compares the least squares estimate of that slope with the value of the sample variance, and rejects the null hypothesis if these two quantities differ significantly.
Tests based on the empirical distribution function:
Bayesian analysis of normally distributed data is complicated by the many different possibilities that may be considered:
Either the mean, or the variance, or neither, may be considered a fixed quantity.
When the variance is unknown, analysis may be done directly in terms of the variance, or in terms of the
precision, the reciprocal of the variance. The reason for expressing the formulas in terms of precision is that the analysis of most cases is simplified.
Both univariate and
multivariate cases need to be considered.
The formulas for the non-linear-regression cases are summarized in the
conjugate prior article.
Sum of two quadratics
Scalar form
The following auxiliary formula is useful for simplifying the
posterior update equations, which otherwise become fairly tedious.
This equation rewrites the sum of two quadratics in x by expanding the squares, grouping the terms in x, and
completing the square. Note the following about the complex constant factors attached to some of the terms:
This shows that this factor can be thought of as resulting from a situation where the
reciprocals of quantities a and b add directly, so to combine a and b themselves, it is necessary to reciprocate, add, and reciprocate the result again to get back into the original units. This is exactly the sort of operation performed by the
harmonic mean, so it is not surprising that is one-half the
harmonic mean of a and b.
Vector form
A similar formula can be written for the sum of two vector quadratics: If x, y, z are vectors of length k, and A and B are
symmetric,
invertible matrices of size , then
where
The form x′ Ax is called a
quadratic form and is a
scalar:
In other words, it sums up all possible combinations of products of pairs of elements from x, with a separate coefficient for each. In addition, since , only the sum matters for any off-diagonal elements of A, and there is no loss of generality in assuming that A is
symmetric. Furthermore, if A is symmetric, then the form
Sum of differences from the mean
Another useful formula is as follows:
where
With known variance
For a set of
i.i.d. normally distributed data points X of size n where each individual point x follows with known
variance σ2, the
conjugate prior distribution is also normally distributed.
This can be shown more easily by rewriting the variance as the
precision, i.e. using τ = 1/σ2. Then if and we proceed as follows.
First, the
likelihood function is (using the formula above for the sum of differences from the mean):
Then, we proceed as follows:
In the above derivation, we used the formula above for the sum of two quadratics and eliminated all constant factors not involving μ. The result is the
kernel of a normal distribution, with mean and precision , i.e.
This can be written as a set of Bayesian update equations for the posterior parameters in terms of the prior parameters:
That is, to combine n data points with total precision of nτ (or equivalently, total variance of n/σ2) and mean of values , derive a new total precision simply by adding the total precision of the data to the prior total precision, and form a new mean through a precision-weighted average, i.e. a
weighted average of the data mean and the prior mean, each weighted by the associated total precision. This makes logical sense if the precision is thought of as indicating the certainty of the observations: In the distribution of the posterior mean, each of the input components is weighted by its certainty, and the certainty of this distribution is the sum of the individual certainties. (For the intuition of this, compare the expression "the whole is (or is not) greater than the sum of its parts". In addition, consider that the knowledge of the posterior comes from a combination of the knowledge of the prior and likelihood, so it makes sense that we are more certain of it than of either of its components.)
The above formula reveals why it is more convenient to do
Bayesian analysis of
conjugate priors for the normal distribution in terms of the precision. The posterior precision is simply the sum of the prior and likelihood precisions, and the posterior mean is computed through a precision-weighted average, as described above. The same formulas can be written in terms of variance by reciprocating all the precisions, yielding the more ugly formulas
With known mean
For a set of
i.i.d. normally distributed data points X of size n where each individual point x follows with known mean μ, the
conjugate prior of the
variance has an
inverse gamma distribution or a
scaled inverse chi-squared distribution. The two are equivalent except for having different
parameterizations. Although the inverse gamma is more commonly used, we use the scaled inverse chi-squared for the sake of convenience. The prior for σ2 is as follows:
For a set of
i.i.d. normally distributed data points X of size n where each individual point x follows with unknown mean μ and unknown
variance σ2, a combined (multivariate)
conjugate prior is placed over the mean and variance, consisting of a
normal-inverse-gamma distribution.
Logically, this originates as follows:
From the analysis of the case with unknown mean but known variance, we see that the update equations involve
sufficient statistics computed from the data consisting of the mean of the data points and the total variance of the data points, computed in turn from the known variance divided by the number of data points.
From the analysis of the case with unknown variance but known mean, we see that the update equations involve sufficient statistics over the data consisting of the number of data points and
sum of squared deviations.
Keep in mind that the posterior update values serve as the prior distribution when further data is handled. Thus, we should logically think of our priors in terms of the sufficient statistics just described, with the same semantics kept in mind as much as possible.
To handle the case where both mean and variance are unknown, we could place independent priors over the mean and variance, with fixed estimates of the average mean, total variance, number of data points used to compute the variance prior, and sum of squared deviations. Note however that in reality, the total variance of the mean depends on the unknown variance, and the sum of squared deviations that goes into the variance prior (appears to) depend on the unknown mean. In practice, the latter dependence is relatively unimportant: Shifting the actual mean shifts the generated points by an equal amount, and on average the squared deviations will remain the same. This is not the case, however, with the total variance of the mean: As the unknown variance increases, the total variance of the mean will increase proportionately, and we would like to capture this dependence.
This suggests that we create a conditional prior of the mean on the unknown variance, with a hyperparameter specifying the mean of the
pseudo-observations associated with the prior, and another parameter specifying the number of pseudo-observations. This number serves as a scaling parameter on the variance, making it possible to control the overall variance of the mean relative to the actual variance parameter. The prior for the variance also has two hyperparameters, one specifying the sum of squared deviations of the pseudo-observations associated with the prior, and another specifying once again the number of pseudo-observations. Each of the priors has a hyperparameter specifying the number of pseudo-observations, and in each case this controls the relative variance of that prior. These are given as two separate hyperparameters so that the variance (aka the confidence) of the two priors can be controlled separately.
This leads immediately to the
normal-inverse-gamma distribution, which is the product of the two distributions just defined, with
conjugate priors used (an
inverse gamma distribution over the variance, and a normal distribution over the mean, conditional on the variance) and with the same four parameters just defined.
The priors are normally defined as follows:
The update equations can be derived, and look as follows:
The respective numbers of pseudo-observations add the number of actual observations to them. The new mean hyperparameter is once again a weighted average, this time weighted by the relative numbers of observations. Finally, the update for is similar to the case with known mean, but in this case the sum of squared deviations is taken with respect to the observed data mean rather than the true mean, and as a result a new interaction term needs to be added to take care of the additional error source stemming from the deviation between prior and data mean.