Inprobability theory andstatistics, thelaw of the unconscious statistician, orLOTUS, is a theorem which expresses theexpected value of afunctiong(X) of arandom variableX in terms ofg and theprobability distribution ofX.
The form of the law depends on the type of random variableX in question. If the distribution ofX isdiscrete and one knows itsprobability mass functionpX, then the expected value ofg(X) iswhere the sum is over all possible valuesx ofX. If instead the distribution ofX iscontinuous withprobability density functionfX, then the expected value ofg(X) is
Both of these special cases can be expressed in terms of thecumulative probability distribution functionFX ofX, with the expected value ofg(X) now given by theLebesgue–Stieltjes integral
In even greater generality,X could be arandom element in anymeasurable space, in which case the law is given in terms ofmeasure theory and theLebesgue integral. In this setting, there is no need to restrict the context toprobability measures, and the law becomes a general theorem ofmathematical analysis on Lebesgue integration relative to apushforward measure.
This proposition is (sometimes) known as thelaw of the unconscious statistician because of a purported tendency to think of the aforementioned law as the very definition of the expected value of a functiong(X) and a random variableX, rather than (more formally) as a consequence of the true definition of expected value.[1] The naming is sometimes attributed toSheldon Ross' textbookIntroduction to Probability Models, although he removed the reference in later editions.[2] Many statistics textbooks do present the result as the definition of expected value.[3]
A similar property holds forjoint distributions, or equivalently, forrandom vectors. For discrete random variablesX andY, a function of two variablesg, and joint probability mass function:[4]In theabsolutely continuous case, with being the joint probability density function,
A number of special cases are given here. In the simplest case, where the random variableX takes on countably many values (so that its distribution is discrete), the proof is particularly simple, and holds without modification ifX is a discreterandom vector or even a discreterandom element.
The case of acontinuous random variable is more subtle, since the proof in generality requires subtle forms of the change-of-variables formula for integration. However, in the framework ofmeasure theory, the discrete case generalizes straightforwardly to general (not necessarily discrete)random elements, and the case of a continuous random variable is then a special case by making use of theRadon–Nikodym theorem.
Suppose thatX is a random variable which takes on only finitely or countably many different valuesx1,x2, ..., with probabilitiesp1,p2, .... Then for any functiong of these values, the random variableg(X) has valuesg(x1),g(x2), ..., although some of these may coincide with each other. For example, this is the case ifX can take on both values1 and−1 andg(x) =x2.
Lety1,y2, ... enumerate the possibledistinct values of, and for eachi letIi denote the collection of allj withg(xj) =yi. Then, according to the definition of expected value, there is
Since a can be the image of multiple, distinct, it holds that
Then the expected value can be rewritten asThis equality relates the average of the outputs ofg(X) as weighted by the probabilities of the outputs themselves to the average of the outputs ofg(X) as weighted by the probabilities of the outputs ofX.
IfX takes on only finitely many possible values, the above is fully rigorous. However, ifX takes on countably many values, the last equality given does not always hold, as seen by theRiemann series theorem. Because of this, it is necessary to assume theabsolute convergence of the sums in question.[5]
Suppose thatX is a random variable whose distribution has a continuous densityf. Ifg is a general function, then the probability thatg(X) is valued in a set of real numbersK equals the probability thatX is valued ing−1(K), which is given byUnder various conditions ong, thechange-of-variables formula for integration can be applied to relate this to an integral overK, and hence to identify the density ofg(X) in terms of the density ofX. In the simplest case, ifg is differentiable with nowhere-vanishing derivative, then the above integral can be written asthereby identifyingg(X) as possessing the densityf (g−1(y))(g−1)′(y). The expected value ofg(X) is then identified aswhere the equality follows by another use of the change-of-variables formula for integration. This shows that the expected value ofg(X) is encoded entirely by the functiong and the densityf ofX.[6]
The assumption thatg is differentiable with nonvanishing derivative, which is necessary for applying the usual change-of-variables formula, excludes many typical cases, such asg(x) =x2. The result still holds true in these broader settings, although the proof requires more sophisticated results frommathematical analysis such asSard's theorem and thecoarea formula. In even greater generality, using theLebesgue theory as below, it can be found that the identityholds true wheneverX has a densityf (which does not have to be continuous) and wheneverg is ameasurable function for whichg(X) has finite expected value. (Every continuous function is measurable.) Furthermore, without modification to the proof, this holds even ifX is arandom vector (with density) andg is a multivariable function; the integral is then taken over the multi-dimensional range of values ofX.
An abstract and general form of the result is available using the framework ofmeasure theory and theLebesgue integral. Here, the setting is that of ameasure space(Ω,μ) and ameasurable mapX fromΩ to ameasurable spaceΩ'. The theorem then says that for any measurable functiong onΩ' which is valued inreal numbers (or even theextended real number line), there is(interpreted as saying, in particular, that either side of the equality exists if the other side exists). HereX♯μ denotes thepushforward measure onΩ′. The 'discrete case' given above is the special case arising whenX takes on only countably many values andμ is aprobability measure. In fact, the discrete case (although without the restriction to probability measures) is the first step in proving the general measure-theoretic formulation, as the general version follows therefrom by an application of themonotone convergence theorem.[7] Without any major changes, the result can also be formulated in the setting ofouter measures.[8]
Ifμ is aσ-finite measure, the theory of theRadon–Nikodym derivative is applicable. In the special case that the measureX♯μ isabsolutely continuous relative to some background σ-finite measureν onΩ′, there is a real-valued functionfX onΩ' representing theRadon–Nikodym derivative of the two measures, and thenIn the further special case thatΩ′ is thereal number line, as in the contexts discussed above, it is natural to takeν to be theLebesgue measure, and this then recovers the 'continuous case' given above wheneverμ is aprobability measure. (In this special case, the condition of σ-finiteness is vacuous, since Lebesgue measure and every probability measure are trivially σ-finite.)[9]