This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# Expectation

 Expectation gives the expectation of expr under the assumption that x follows the probability distribution dist. Expectationgives the expectation of expr under the assumption that x follows the probability distribution given by data. Expectationgives the expectation of expr under the assumption that follows the multivariate distribution dist. Expectationgives the expectation of expr under the assumption that , , ... are independent and follow the distributions , , .... Expectationgives the conditional expectation of expr given pred.
• can be entered as x Esc dist Esc dist or .
• can be entered as expr Esc cond Esc pred or .
• For a continuous distribution dist, the expectation of expr is given by where is the probability density function of dist and the integral is taken over the domain of dist.
• For a discrete distribution dist, the probability of expr is given by where is the probability density function of dist and the summation is taken over the domain of dist.
• For a dataset data, the expectation of expr is given by Sum[expr, {x, data}]/Length[data].
• Univariate data is given as a list of values and multivariate data is given as a list of vectors .
• N calls NExpectation for expectations that cannot be done symbolically.
• The following options can be given:
 Assumptions \$Assumptions assumptions to make about parameters GenerateConditions False whether to generate conditions on parameters Method Automatic what method to use
Compute the expectation of a polynomial expression:
Compute the expectation of an arbitrary expression:
Compute a conditional expectation:
Compute the expectation of a polynomial expression:
 Out[1]=
 Out[2]=
 Out[3]=
 Out[4]=

Compute the expectation of an arbitrary expression:
 Out[1]=
 Out[2]=
 Out[3]=

Compute a conditional expectation:
 Out[1]=
 Out[2]=
 Scope   (25)
Compute the expectation for an expression in a continuous univariate distribution:
Discrete univariate distribution:
Continuous multivariate distribution:
Discrete multivariate distribution:
Find the expectation of an expression in a distribution specified by a list:
Compute the expectation using independently distributed random variables:
Find the conditional expectation with general nonzero probability conditioning:
Discrete univariate distribution:
Multivariate continuous distribution:
Multivariate discrete distribution:
Compute the conditional expectation with a zero-probability conditioning event:
Apply N to invoke NExpectation if symbolic evaluation fails:
With no Assumptions, conditions are generated:
With Assumptions, a result valid under the given assumptions is returned:
Find the expectation of a rational function:
Transcendental function:
Piecewise function:
Complex function:
Compute expectations for univariate continuous distributions:
Compute expectations for univariate discrete distributions:
Expectations for multivariate continuous distributions:
Expectations for multivariate discrete distributions:
Compute an expectation using a univariate EmpiricalDistribution:
Using a multivariate empirical distribution:
Using a univariate HistogramDistribution:
A multivariate histogram distribution:
Using a univariate KernelMixtureDistribution:
Using censored data with SurvivalDistribution:
Compute the expectation using a TransformedDistribution:
An equivalent way of formulating the same expectation:
Find the expectation using a ProductDistribution:
An equivalent formulation for the same expectation:
Using a component mixture of normal distributions:
Parameter mixture of exponential distributions:
Truncated Dirichlet distribution:
Censored triangular distribution:
Marginal distribution:
An equivalent way of formulating the same expectation:
Copula distribution:
Formula distribution:
Use a pure function to compute an expectation for a list of values:
 Options   (4)
With no Assumptions, conditions are generated:
With Assumptions, a result valid under the given assumptions is returned:
Compute the expectation of a polynomial function:
Obtain the same result using the moments of the distribution:
The evaluation is slower using the definition of Expectation as an integral:
Compute the expectation of a transcendental function:
Here, the method based on moments fails because the expression is nonpolynomial:
The result can be obtained using the definition of Expectation as a symbolic sum:
Find the expectation of a function in a TukeyLambdaDistribution:
The PDF of this distribution is not available in closed form:
Hence a direct application of the definition fails:
The expectation can be computed using Quantile:
 Applications   (20)
Obtain the raw moments of a continuous distribution:
Obtain the mean of a discrete distribution:
Obtain the variance of a truncated distribution:
Construct a mixture density, here a Poisson-inverse Gaussian mixture:
Obtain the same result directly using ParameterMixtureDistribution:
Verify Jensen inequality for a concave function and a lognormal distribution:
An insurance policy reimburses a loss up to a benefit limit of 10. The policy holder's loss follows a distribution with density function for and 0 otherwise. Find the expected value of the benefit paid under the insurance policy:
An insurance company's monthly claims are modeled by a continuous, positive random variable , whose probability density function is proportional to where . Determine the company's expected monthly claims:
Claim amounts for wind damage to insured homes are independent random variables with common density function for and 0 otherwise, where is the amount of a claim in thousands. Suppose three such claims will be made. Find the expected value of the largest of the three claims:
Let represent the age of an insured automobile involved in an accident. Let represent the length of time the owner has insured the automobile at the time of the accident. and have joint probability density function for and , and 0 otherwise. Calculate the expected age of an insured automobile involved in an accident:
Under an excess of loss reinsurance agreement, a claim is shared between the insurer and reinsurer only if the claim exceeds a fixed amount, called the retention level. Otherwise, the insurer pays the claim in full. Compute the expected value of the amounts, and , paid by the insurer and the reinsurer for a retention level of if the claims follow a lognormal distribution with parameters and . Find the expected insurer claim payouts:
Find the expected reinsurer payouts to the insurer:
Compute the expected time value of a death benefit of \$1 paid at time , where is drawn from a Gompertz-Makeham distribution:
Find the annual premium, which is usually paid at the beginning of a policy year, that is necessary to make the expected time value of that payment stream for periods (where is drawn from a Gompertz-Makeham distribution) equal to the net single premium:
The fractional change of stock price at time (in years) is assumed lognormally distributed with parameters and :
Compute the expected stock price at epoch :
Assuming an investor can invest money for a year at a continuously compounded yearly rate risk-free, the risk-neutral pricing condition requires:
Solve for parameter :
Consider an option to buy this stock a year from now, at a fixed price . The value of such an option is:
The risk-neutral price of the option is determined as the present value of the expected option value:
Assuming rate of 5%, volatility parameter of 0.087, an initial price of \$200 per share of stock, and a strike price of \$190 per share, the Black-Scholes option price is:
Study the tail value at risk (TVaR) for the exponential distribution:
Find the mean time to failure (MTTF) for an exponential life distribution:
A random sample of size 10 from a continuous distribution is sorted in ascending order. A new random variate is generated. Find the probability that the 11 sample falls between the fourth and fifth smallest values in the sorted list:
The probability equals and is independent of :
It is also independent of the distribution:
Four six-sided dice are rolled. Find the expectation of the minimum value:
Find the expectation of the maximum value:
Find the expectation of the sum of the three largest values. Using the identity and linearity of Expectation you get:
A player bets amount in a casino with no betting limit in a game with a chance of winning . If he loses he doubles the bet, and if he wins he quits, hence the number of games played follows a geometric distribution, with expected number of games played represented as follows:
The cash reserve needed to win the game:
The player always leaves the casino collecting the amount of the initial bet:
The cash reserve needed to execute the above strategy is finite only for strictly favorable games, where :
A drug has proven to be effective in 40% of cases. Find the expected number of successes when applied to 700 cases:
A baseball player is a 0.300 hitter. Find the expected number of hits if the player comes to bat 3 times:
Find the mean if the signal-to-noise ratio has a Weibull distribution:
The expectation of an expression in a continuous distribution is defined by an integral:
The expectation of an expression in a discrete distribution is defined by a sum:
A conditional expectation is defined by a ratio of expectation and probability:
Use NExpectation to find the numerical value of an expectation:
Compute the probability of an event:
Obtain the same result using Expectation:
N is equivalent to NExpectation if symbolic evaluation fails:
Mean, Moment, Variance, and other properties are defined as expectations:
Generating functions including MomentGeneratingFunction are defined by an expectation:
For a distribution specified by a list, Expectation is equivalent to using Mean:
New in 8