In [26]:
# statistics, pg 97
import random
from collections import Counter
import matplotlib.pyplot as plt
In [21]:
num_friends = [random.randint(0, 100) for _ in range(100)]
In [22]:
print num_friends
In [23]:
friend_counts = Counter(num_friends)
xs = range(101)
ys = [friend_counts[x] for x in xs]
In [24]:
print ys
In [29]:
plt.bar(xs, ys)
plt.axis([0, 101, 0, 6])
plt.title("Hist of Friend Counts")
plt.xlabel("# of Friends")
plt.ylabel("# of people")
plt.show()
In [33]:
# number of data points
num_points = len(num_friends)
# max and min values
max_point = max(num_friends)
min_point = min(num_friends)
print num_points, max_point, min_point
In [ ]:
In [ ]:
In [ ]: