This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

NExpectation

NExpectation
gives the numerical expectation of expr under the assumption that x follows the probability distribution dist.
NExpectation
gives the numerical expectation of expr under the assumption that follows the multivariate distribution dist.
NExpectation
gives the numerical expectation of expr under the assumption that , , ... are independent and follow the distributions , , ....
NExpectation
gives the numerical 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.
  • The following options can be given:
AccuracyGoaldigits of absolute accuracy sought
PrecisionGoalAutomaticdigits of precision sought
WorkingPrecisionMachinePrecisionthe precision used in internal computations
MethodAutomaticwhat 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:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
 
Compute the expectation of an arbitrary expression:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
 
Compute a conditional expectation:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Compute the expectation for an expression in a continuous univariate distribution:
Discrete univariate distribution:
Continuous multivariate distribution:
Discrete multivariate distribution:
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:
Find the expectation of a rational function:
Transcendental function:
Piecewise function:
Complex function:
Obtain results with different precisions:
Compute expectations for univariate continuous distributions:
Compute expectations for univariate discrete distributions:
Expectations for multivariate continuous distributions:
Expectations for multivariate discrete distributions:
Using a univariate HistogramDistribution:
A multivariate histogram distribution:
Using a univariate KernelMixtureDistribution:
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 formulation for the same expectation:
Copula distribution:
Formula distribution:
Obtain a result with the default setting for accuracy:
Use AccuracyGoal to obtain the result with a different accuracy:
Here, the default number of recursive bisections gives a result with low accuracy:
Use the Method option to increase the number of recursive bisections:
Compare with the exact result from Expectation:
Obtain a result with the default setting for precision:
Use PrecisionGoal to obtain the result with a different precision:
By default, NExpectation uses machine precision:
Use WorkingPrecision to obtain results with higher precision:
Obtain a raw moment for a continuous distribution:
Obtain the mean of a discrete distribution:
Obtain the variance of a truncated distribution:
An insurance policy reimburses a loss up to a benefit limit of 10. The policyholder'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 3 such claims will be made. Compute 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:
A baseball player is a 0.300 hitter. Find the expected number of hits if the player comes to bat 3 times:
A basketball player shoots free throws until he hits 4 of them. His probability of scoring in any one of them is 0.7. Find the number of shots the player is expected to shoot:
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 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^(th) 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:
Study the tail value at risk (TVaR) for the exponential distribution:
Value at risk may underestimate possible losses. Consider two models for stock log-returns:
Fix parameter so that values at risk at the 99.5% level are equal:
Now compute the expected losses in both models, given that they exceed the value at risk:
The losses are actually bigger in the second model:
A drug has proven to be effective in 40% of cases. Find the expected number of successes when applied to 100 cases:
Assuming stock logarithmic return follows a stable distribution, find the value at risk at the 95% level:
Compute the 95% value at risk point loss of the current S&P 500 index value, assuming the above distribution:
Find the expected shortfall of logarithmic return:
Compute the associated point loss:
A site has mean wind speed 7 m/s and Weibull distribution with shape parameter 2:
The resulting wind speed distribution over a whole year:
The power curve for a GE 1.5 MW wind turbine:
The total mean energy produced over the course of a year is then 4.3 MWh:
Estimate the distribution of the lengths of human chromosomes:
The expected chromosome length, given that the length is greater than the mean:
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:
Mean, Moment, Variance, and other properties are defined as expectations:
Use Expectation to find a symbolic expression for an expectation:
N[Expectation[...]] is equivalent to NExpectation if symbolic evaluation fails:
Compute the probability of an event:
Obtain the same result using NExpectation:
New in 8