SOCR BivariateNormal JS Activity
Contents
SOCR Educational Materials - Activities - SOCR Bivariate Normal Distribution Activity
This activity represents a 3D rendering of the Bivariate Normal Distribution. It is implemented in HTML5/JavaScript and should be portable on any computer, operating system and web-browser.
Goals
The aims of this activity are to:
- To clarify the definitions and interplay between marginal, conditional and joint probability distributions (in the bivariate Normal case)
- To learn how to calculate Normal marginal conditional and joint probabilities.
- To demonstrate that when X and Y have joint bivariate normal distribution with zero correlation, then X and Y must be independent.
Background
- In general, when X and Y are jointly continuous random variables with a joint density \(ƒ_{X,Y}(x,y)\), if A and B (non-trivial) are subsets of the ranges of X and Y (e.g., intervals), then:
- \( P(X \in A \mid Y \in B) = \frac{\int_{y\in B}\int_{x\in A} f_{X,Y}(x,y)\,dx\,dy}{\int_{y\in B}\int_{x\in\Omega} f_{X,Y}(x,y)\,dx\,dy}. \)
- In the special case where B={y0}, representing a single point, the conditional probability is:
- \( P(X \in A \mid Y = y_0) = \frac{\int_{x\in A} f_{X,Y}(x,y_0)\,dx}{\int_{x\in\Omega} f_{X,Y}(x,y_0)\,dx}. \). If the set (range) A is trivial, then the conditional probability is zero.
- Suppose that X has normal distribution, the conditional mean of X given \(Y=y_o\), \(E(X|Y=y_o)\), is linear in Y, and the conditional variance of X given \(y_o\), \(Var(X|y_0)\), is constant. Then, the conditional probability distribution of X given Y = \(y_0\), \(f_{X|Y=y_o}\), is given by:
- \( f_{X|y_o} \sim N \left ( \mu_{X|y_o} = \mu_X +\rho \frac{\sigma_X}{\sigma_Y}(y_o-\mu_Y), \sigma_{X|y_o}^2 = \sigma_X^2(1-\rho^2) \right) \), where
- \( X \sim N (\mu_X, \sigma_X^2) \),
- \( E(Y)=\mu_Y\), and \(VAR(Y)=E(Y^2)-\mu_Y^2 = \sigma_Y^2) \), But this does not necessarily require that Y is normally distributed itself!
- \( \rho = Corr(X,Y)\) is the correlation between X and Y.
- This expression of the density assumes that the conditional mean of X given \(y_o\) is linear in y and the conditional variance of X given \(y_o\) is constant.
- The above does not make assumption about the distribution of Y. Now assume Y is also normally distributed with \( Y \sim N (\mu_Y, \sigma_Y^2) \). We have 3 important observations:
- The density of Y is:
- \( f_Y = \frac{1}{\sigma_Y \sqrt{2\pi}} e^{-\frac{(y-\mu_y)^2}{2\sigma_Y^2}} \),
- The conditional distribution of \(X\) given \(Y = y_o\) is:
- \( g_{X|Y}(x|y) = \frac{1}{\sigma_{X|Y} \sqrt{2\pi}} e^{-\frac{(x-\mu_{X|Y})^2}{2\sigma_{X|Y}^2}} \),
- \( = \frac{1}{\sigma_X\sqrt{1-\rho^2} \sqrt{2\pi}} e^{-\frac{(x-\mu_X-\rho\frac{\sigma_X}{\sigma_Y}(Y-\mu_Y))^2}{2\sigma_X^2(1-\rho^2)}} \)
- \( g_{X|Y}(x|y) = \frac{1}{\sigma_{X|Y} \sqrt{2\pi}} e^{-\frac{(x-\mu_{X|Y})^2}{2\sigma_{X|Y}^2}} \),
- The joint probability density function of \(X\) and \(Y\) is:
- \( f_{X,Y}(x,y) = g_{X|Y}(x|y)f_Y(y) = \frac{1}{\sigma_X\sigma_Y 2\pi\sqrt{1-\rho^2}} e^{-q(x,y)} \), where
- \( q(x,y) = \frac{1}{2} \frac{1}{1-\rho^2} \left ( \left ( \frac{X-\mu_X}{\sigma_X} \right )^2 -2\rho\frac{X-\mu_X}{\sigma_X}\frac{Y-\mu_Y}{\sigma_Y} +\left ( \frac{Y-\mu_Y}{\sigma_Y} \right )^2 \right ) \).
- \( f_{X,Y}(x,y) = g_{X|Y}(x|y)f_Y(y) = \frac{1}{\sigma_X\sigma_Y 2\pi\sqrt{1-\rho^2}} e^{-q(x,y)} \), where
Requirements
A modern web-browser with HTML and JavaScript support is required (mobile devices should be fine). The 3D view of the bivariate Normal distribution requires WebGL support, however this is not absolutely necessary. If you toggle off the "Use WebGL" check-box in the Settings panel you can view the 3D grid/mesh representation of the 2D Normal/Gaussian distribution without WebGL.
- Go to the SOCR Bivariate Normal Distribution Webapp.
- Use the Settings to initialize the web-app.
- In the Control panel:
- Select the appropriate bivariate limits for the X and Y variables.
- Choose desired Marginal or Conditional probability function.
- 1D Normal Distribution graph will be shown to the right.
- You can rotate and manipulate the bivariate normal distribution in 3D by clicking and dragging on the graph below.
- Probability Results are reported in the bottom text area.
Experiment 1
Questions
... TBD ...
Applications
... TBD ...
References
- Dinov, ID, Christou, N and Sanchez, J. (2008) Central Limit Theorem: New SOCR Applet and Demonstration Activity, Journal of Statistics Education, Volume 16, Number 2.
Translate this page: