Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Section 2.5 — Multiple continuous random variables

This notebook contains all the code examples from Section 2.5 Multiple continuous random variables of the No Bullshit Guide to Statistics.

Notebook setup

We’ll start by importing the Python modules we’ll need for this notebook.


[notice] A new release of pip is available: 26.0.1 -> 26.2
[notice] To update, run: pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
<Figure size 640x480 with 0 Axes>

Joint probability density function

Example 1: bivariate normal distribution

TODO: formula for general bivarate normal

0.08020655225672235

Probability of the event {10≤X≤14,5≤Y≤7}\{10 \leq X \leq 14, 5 \leq Y \leq 7\}.

0.2905021692650627
0.2905021692650628

Unit total axiom

1.000000000045008

TODO: formulas

<Figure size 700x400 with 1 Axes>
<Figure size 700x400 with 1 Axes>
<Figure size 700x400 with 1 Axes>
<Figure size 700x700 with 1 Axes>

Marginal distribution functions

TODO: formulas

<Figure size 700x200 with 1 Axes>
<Figure size 700x200 with 1 Axes>
<Figure size 700x400 with 3 Axes>

Conditional probability distributions

<Figure size 700x200 with 1 Axes>
<Figure size 700x400 with 1 Axes>
<Figure size 700x400 with 1 Axes>

The chain rule

Example 2: bivariate uniform over a triangle

<Figure size 700x700 with 1 Axes>
<Figure size 500x500 with 1 Axes>

Checking Kolmogorov’s second axiom

1.0

Computing probabilities

0.25

Marginal distributions

<Figure size 400x400 with 3 Axes>

Conditional distributions

<Figure size 600x300 with 3 Axes>

Bayes’ rule formula

Example 2 (continued): Bayes’ rule calculation

Multivariable expectation

Means

Covariance

Correlation

Example 1 revisited: computer model for the bivariate normal

Mean

array([10., 5.])

Covariance

array([[9. , 2.25], [2.25, 1. ]])
2.25

Correlation

0.75

Independent random variables

TODO formulas

Example 3: sum of two independent random variables

Independent, identically distributed random variabls

Example 4: average of nn standard normals

Discussion

Exercises