Created
May 27, 2015 16:02
-
-
Save Gabriel-p/0c49727ac45ce23e846b 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 | |
import matplotlib.pyplot as plt | |
def cluster_stars(N, min_v, max_v): | |
''' | |
''' | |
mu = np.random.uniform(min_v, max_v) | |
sigma = np.random.uniform(max_v / 10., min_v / 10.) | |
print mu, sigma | |
points = zip([np.random.normal(mu, sigma, N), | |
np.random.normal(mu, sigma, N)]) | |
return points, 2 * sigma, [mu, mu] | |
def main(): | |
# Synthetic cluster. | |
N, min_v, max_v = 200, 0., 10. | |
points, clust_rad, center = cluster_stars(N, min_v, max_v) | |
# Synthetic field. | |
N = 1000 | |
field = zip([np.random.uniform(min_v, max_v, N), | |
np.random.uniform(min_v, max_v, N)]) | |
# Plot. | |
fig = plt.figure() | |
fig.add_subplot(111, aspect='equal') | |
# Plot radius. | |
circle = plt.Circle((center[0], center[1]), clust_rad, color='k', | |
fill=False, lw=1.5) | |
fig.gca().add_artist(circle) | |
# Plot field points. | |
plt.scatter(*field, s=10, c='b', zorder=2) | |
# Plot cluster points. | |
plt.scatter(*points, s=10, c='r', zorder=3) | |
# Plot cluster center. | |
plt.scatter(*center, s=70, c='g', zorder=4) | |
plt.show() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment