Box plot and probability density function of anormal distributionN(0, σ2).Geometric visualisation of themode,median andmean of an arbitrary unimodal probability density function.[1]
Inprobability theory, aprobability density function (PDF),density function, ordensity of anabsolutely continuous random variable, is afunction whose value at any given sample (or point) in thesample space (the set of possible values taken by the random variable) can be interpreted as providing arelative likelihood that the value of the random variable would be equal to that sample.[2][3] Probability density is the probability per unit length, in other words, while theabsolute likelihood for a continuous random variable to take on any particular value is 0 (since there is an infinite set of possible values to begin with), the value of the PDF at two different samples can be used to infer, in any particular draw of the random variable, how much more likely it is that the random variable would be close to one sample compared to the other sample.
More precisely, the PDF is used to specify the probability of therandom variable fallingwithin a particular range of values, as opposed to taking on any one value. This probability is given by theintegral of this variable's PDF over that range—that is, it is given by the area under the density function but above the horizontal axis and between the lowest and greatest values of the range. The probability density function is nonnegative everywhere, and the area under the entire curve is equal to 1.
The termsprobability distribution function andprobability function have also sometimes been used to denote the probability density function. However, this use is not standard among probabilists and statisticians. In other sources, "probability distribution function" may be used when theprobability distribution is defined as a function over general sets of values or it may refer to thecumulative distribution function, or it may be aprobability mass function (PMF) rather than the density. "Density function" itself is also used for the probability mass function, leading to further confusion.[4] In general though, the PMF is used in the context ofdiscrete random variables (random variables that take values on a countable set), while the PDF is used in the context of continuous random variables.
Examples of four continuous probability density functions.
Suppose bacteria of a certain species typically live 20 to 30 hours. The probability that a bacterium livesexactly 5 hours is equal to zero. A lot of bacteria live for approximately 5 hours, but there is no chance that any given bacterium dies at exactly 5.00... hours. However, the probability that the bacterium dies between 5 hours and 5.01 hours is quantifiable. Suppose the answer is 0.02 (i.e., 2%). Then, the probability that the bacterium dies between 5 hours and 5.001 hours should be about 0.002, since this time interval is one-tenth as long as the previous. The probability that the bacterium dies between 5 hours and 5.0001 hours should be about 0.0002, and so on.
In this example, the ratio (probability of living during an interval) / (duration of the interval) is approximately constant, and equal to 2 per hour (or 2 hour−1). For example, there is 0.02 probability of dying in the 0.01-hour interval between 5 and 5.01 hours, and (0.02 probability / 0.01 hours) = 2 hour−1. This quantity 2 hour−1 is called the probability density for dying at around 5 hours. Therefore, the probability that the bacterium dies at 5 hours can be written as (2 hour−1)dt. This is the probability that the bacterium dies within an infinitesimal window of time around 5 hours, wheredt is the duration of this window. For example, the probability that it lives longer than 5 hours, but shorter than (5 hours + 1 nanosecond), is (2 hour−1)×(1 nanosecond) ≈6×10−13 (using theunit conversion3.6×1012 nanoseconds = 1 hour).
There is a probability density functionf withf(5 hours) = 2 hour−1. Theintegral off over any window of time (not only infinitesimal windows but also large windows) is the probability that the bacterium dies in that window.
It is not possible to define a density with reference to an arbitrary measure (e.g. one can not choose the counting measure as a reference for a continuous random variable). Furthermore, when it does exist, the density is almost unique, meaning that any two such densities coincidealmost everywhere.
Unlike a probability, a probability density function can take on values greater than one; for example, thecontinuous uniform distribution on the interval[0, 1/2] has probability densityf(x) = 2 for0 ≤x ≤ 1/2 andf(x) = 0 elsewhere.
If a random variableX is given and its distribution admits a probability density functionf, then theexpected value ofX (if the expected value exists) can be calculated as
Not every probability distribution has a density function: the distributions ofdiscrete random variables do not; nor does theCantor distribution, even though it has no discrete component, i.e., does not assign positive probability to any individual point.
In the field ofstatistical physics, a non-formal reformulation of the relation above between the derivative of the cumulative distribution function and the probability density function is generally used as the definition of the probability density function. This alternate definition is the following:
Ifdt is an infinitely small number, the probability thatX is included within the interval(t,t +dt) is equal tof(t)dt, or:
Link between discrete and continuous distributions
It is possible to represent certain discrete random variables as well as random variables involving both a continuous and a discrete part with ageneralized probability density function using theDirac delta function. (This is not possible with a probability density function in the sense defined above, it may be done with adistribution.) For example, consider a binary discreterandom variable having theRademacher distribution—that is, taking −1 or 1 for values, with probability1⁄2 each. The density of probability associated with this variable is:
More generally, if a discrete variable can taken different values among real numbers, then the associated probability density function is:where are the discrete values accessible to the variable and are the probabilities associated with these values.
This substantially unifies the treatment of discrete and continuous probability distributions. The above expression allows for determining statistical characteristics of such a discrete variable (such as themean,variance, andkurtosis), starting from the formulas given for a continuous distribution of the probability.
It is common for probability density functions (andprobability mass functions) to be parametrized—that is, to be characterized by unspecifiedparameters. For example, thenormal distribution is parametrized in terms of themean and thevariance, denoted by and respectively, giving the family of densitiesDifferent values of the parameters describe different distributions of differentrandom variables on the samesample space (the same set of all possible values of the variable); this sample space is the domain of the family of random variables that this family of distributions describes. A given set of parameters describes a single distribution within the family sharing the functional form of the density. From the perspective of a given distribution, the parameters are constants, and terms in a density function that contain only parameters, but not variables, are part of thenormalization factor of a distribution (the multiplicative factor that ensures that the area under the density—the probability ofsomething in the domain occurring— equals 1). This normalization factor is outside thekernel of the distribution.
Since the parameters are constants, reparametrizing a density in terms of different parameters to give a characterization of a different random variable in the family, means simply substituting the new parameter values into the formula in place of the old ones.
For continuousrandom variablesX1, ...,Xn, it is also possible to define a probability density function associated to the set as a whole, often calledjoint probability density function. This density function is defined as a function of then variables, such that, for any domainD in then-dimensional space of the values of the variablesX1, ...,Xn, the probability that a realisation of the set variables falls inside the domainD is
IfF(x1, ...,xn) = Pr(X1 ≤x1, ...,Xn ≤xn) is thecumulative distribution function of the vector(X1, ...,Xn), then the joint probability density function can be computed as a partial derivative
Fori = 1, 2, ...,n, letfXi(xi) be the probability density function associated with variableXi alone. This is called the marginal density function, and can be deduced from the probability density associated with the random variablesX1, ...,Xn by integrating over all values of the othern − 1 variables:
If the joint probability density function of a vector ofn random variables can be factored into a product ofn functions of one variable(where eachfi is not necessarily a density) then then variables in the set are allindependent from each other, and the marginal probability density function of each of them is given by
This elementary example illustrates the above definition of multidimensional probability density functions in the simple case of a function of a set of two variables. Let us call a 2-dimensional random vector of coordinates(X,Y): the probability to obtain in the quarter plane of positivex andy is
Function of random variables and change of variables in the probability density function
If the probability density function of a random variable (or vector)X is given asfX(x), it is possible (but often not necessary; see below) to calculate the probability density function of some variableY =g(X). This is also called a "change of variable" and is in practice used to generate a random variable of arbitrary shapefg(X) =fY using a known (for instance, uniform) random number generator.
It is tempting to think that in order to find the expected valueE(g(X)), one must first find the probability densityfg(X) of the new random variableY =g(X). However, rather than computingone may find instead
The values of the two integrals are the same in all cases in which bothX andg(X) actually have probability density functions. It is not necessary thatg be aone-to-one function. In some cases the latter integral is computed much more easily than the former. SeeLaw of the unconscious statistician.
This follows from the fact that the probability contained in a differential area must be invariant under change of variables. That is,or
For functions that are not monotonic, the probability density function fory iswheren(y) is the number of solutions inx for the equation, and are these solutions.
Supposex is ann-dimensional random variable with joint densityf. Ify =G(x), whereG is abijective,differentiable function, theny has densitypY:with the differential regarded as theJacobian of the inverse ofG(⋅), evaluated aty.[6]
For example, in the 2-dimensional casex = (x1,x2), suppose the transformG is given asy1 =G1(x1,x2),y2 =G2(x1,x2) with inversesx1 =G1−1(y1,y2),x2 =G2−1(y1,y2). The joint distribution fory = (y1, y2) has density[7]
Let be a differentiable function and be a random vector taking values in, be the probability density function of and be theDirac delta function. It is possible to use the formulas above to determine, the probability density function of, which will be given by
Let be a collapsed random variable with probability density function (i.e., a constant equal to zero). Let the random vector and the transform be defined as
It is clear that is a bijective mapping, and the Jacobian of is given by:which is an upper triangular matrix with ones on the main diagonal, therefore its determinant is 1. Applying the change of variable theorem from the previous section we obtain thatwhich if marginalized over leads to the desired probability density function.
The probability density function of the sum of twoindependent random variablesU andV, each of which has a probability density function, is theconvolution of their separate density functions:
It is possible to generalize the previous relation to a sum of N independent random variables, with densitiesU1, ...,UN:
This can be derived from a two-way change of variables involvingY =U +V andZ =V, similarly to the example below for the quotient of independent random variables.
Products and quotients of independent random variables
Given two independent random variablesU andV, each of which has a probability density function, the density of the productY =UV and quotientY =U/V can be computed by a change of variables.
This method crucially requires that the transformation fromU,V toY,Z bebijective. The above transformation meets this becauseZ can be mapped directly back toV, and for a givenV the quotientU/V ismonotonic. This is similarly the case for the sumU +V, differenceU −V and productUV.
Exactly the same method can be used to compute the distribution of other functions of multiple independent random variables.