Wolfram Demonstrations Project
7899

Estimating Conditional Expectations with Monte Carlo Simulation and Least Squares Regression

In this Demonstration we consider three random variables, and , which are uniformly distributed on the interval [0,1] and , where , , and are (user-specified) non-negative integers. The purpose is to compute the conditional expectation symbolically and by polynomial regression on data obtained from randomly generated sequences (, ). The display shows the graphs of the conditional expectation function (red) and an estimate (green), explicit formulas giving the exact value of the conditional expectation and its polynomial estimate, and the (square-integrable) error of the estimate, obtained by integrating the square of the difference between the true conditional expectation and the estimated one.
Use the controls to choose the values of , , and and the degree of the polynomial to be used in the regression.

SNAPSHOTS

  • [Snapshot]
  • [Snapshot]
  • [Snapshot]

DETAILS

Many problems in science, economics, finance, and so on require us to compute conditional expectations. If and are random variables with nice density, then the conditional expectation can be defined as the orthogonal projection of on the linear subspace space of all functions of in Hilbert space of all (square-integrable) random variables. Thus the conditional expectation can be though of as a function of with the minimum distance from . This justifies the well-known Monte Carlo method of approximating by generating a sample of (, ) pairs and regressing on by solving a least-squares problem for a polynomial of some chosen degree. In this Demonstration we start with two independent random variables and with uniform distribution on [0,1]. As we take a random variable for some positive integers , , and . In this case Mathematica is able to compute the exact formula for , so that we can assess the accuracy of the estimate by computing the norm using numerical integration.
The idea of this Demonstration is based on an example in chapter 11.6 of
K. L. Judd, Numerical Methods in Economics, Cambridge, MA: The MIT Press, 1998.








 
RELATED RESOURCES
Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Powered by Wolfram Mathematica © 2012 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+