|
np.random.multivariate_normal()
import numpy as np
import matplotlib.pyplot as plt
means = [
[9, 9], # top right
[1, 9], # top left
[1, 1], # bottom left
[9, 1], # bottom right
]
covariances = [
[ [.5, 0.], # covariance top right
[0, .5] ],
[[.1, .0], # covariance top left
[.0, .9]],
[[.9, 0.], # covariance bottom left
[0, .1]],
[[0.5, 0.5], # covariance bottom right
[0.5, 0.5]] ]
data = []
for k in range(len(means)):
for i in range(100) :
x = np.random.multivariate_normal(means[k], covariances[k])
data.append(x)
d=np.vstack(data)
plt.plot(d[:,0], d[:,1],'ko')
plt.show()
| |