Created
February 18, 2013 23:48
-
-
Save mrocklin/4981811 to your computer and use it in GitHub Desktop.
Example showing densities of random variables in conditional joint probability space.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy.stats import * | |
from sympy import Tuple, Eq, simplify, Symbol, pprint | |
X = Normal('x', 3, 4) | |
Y = Normal('y', 5, 6) | |
Z = Normal('z', 0, 1) | |
# X, Y, and Z given that Z+Y == X | |
XX, YY, ZZ = given(Tuple(X, Y, Z), Eq(Z+Y, X)) | |
w = Symbol('w') | |
pprint(simplify(density(XX)(w))) | |
# 2 | |
# 53⋅w 191⋅w 36481 | |
# - ───── + ───── - ───── | |
# ______ 1184 592 62752 | |
# ╲╱ 3922 ⋅ℯ | |
# ───────────────────────────────── | |
# ___ | |
# 296⋅╲╱ π |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment