Skip to content

Instantly share code, notes, and snippets.

@yangkky
Created November 1, 2018 00:12
Show Gist options
  • Save yangkky/7c3bf74c23db0a06bf794135c078e298 to your computer and use it in GitHub Desktop.
Save yangkky/7c3bf74c23db0a06bf794135c078e298 to your computer and use it in GitHub Desktop.
import numpy as np
from scipy import stats
n = 100
r = 10
x = np.linspace(-1.8, 1.8, n)
y = np.linspace(-1.8, 1.8, n)
X, Y = np.meshgrid(x, y)
XY = np.empty((n * n, 2))
XY[:, 0] = X.flatten()
XY[:, 1] = Y.flatten()
cov = np.eye(2) * 0.2
dist = stats.multivariate_normal(np.array([-0.6, -0.6]), cov)
Z = dist.pdf(XY).reshape((n, n))
cov = np.eye(2) * 0.2
dist = stats.multivariate_normal(np.array([0.6, 0.6]), cov)
Z += dist.pdf(XY).reshape((n, n))
cov = np.array([[0.1, 0.002],
[0.005, 0.1]])
dist = stats.multivariate_normal(np.array([0.5, -0.5]), cov)
Z += dist.pdf(XY).reshape((n, n)) * 1
cov = np.array([[0.05, 0.002],
[0.003, 0.05]])
dist = stats.multivariate_normal(np.array([-0.5, -1.0]), cov)
Z += dist.pdf(XY).reshape((n, n)) * 0.15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment