Skip to content

Instantly share code, notes, and snippets.

@galenseilis
Created December 19, 2022 01:16
Show Gist options
  • Save galenseilis/259c37af0ed82f26d5a9cfa4776fa8be to your computer and use it in GitHub Desktop.
Save galenseilis/259c37af0ed82f26d5a9cfa4776fa8be to your computer and use it in GitHub Desktop.
Short example of a conditional normal distribution.
import matplotlib.pyplot as plt
import numpy as np
L = np.random.multinomial(1, pvals=[1/3]*3, size=1000)
Q = L @ np.diag([1, 7, 31])
M = np.sum(Q, axis=1)
X = np.random.normal(loc=M, size=M.size)
plt.hist(X, bins=100)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment