Last active
October 22, 2016 16:48
-
-
Save reynoldscem/3cdcdc5b5c5a36120406bbf7a31d12a2 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
from matplotlib import pyplot as plt | |
# Uncomment if you're running in a jupyter notebook | |
# %matplotlib inline | |
axis = (0, 500) | |
sigma = 100 | |
k = 3 | |
ndim = 5 | |
# k (uniform) random points in 2D space in the interval of (0, 500) | |
centers = np.random.uniform(*axis, (k, ndim)) | |
# Show centers | |
plt.figure() | |
plt.scatter(centers[:, 0], centers[:, 1]) | |
# Variance of the distribution | |
cov = np.eye(ndim) * sigma | |
points_to_generate = 5000 | |
# For each center, generate points_to_generate points. | |
points = [ | |
np.random.multivariate_normal(centers[i], cov, points_to_generate) | |
for i in range(k) | |
] | |
colours = ['red', 'green', 'blue'] | |
plt.figure() | |
for i in range(k): | |
plt.scatter(points[i][:, 0], points[i][:, 1], color=colours[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment