Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0febcf

Browse files
committed
Code for statistics.
1 parent45a7e89 commita0febcf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎data-science/statistics.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
fromcollectionsimportCounter
2+
frommatplotlibimportpyplotasplt
3+
importrandom
4+
5+
6+
deffriend_hist():
7+
num_friends= [random.randint(1,120)for_inrange(1025)]
8+
9+
friend_counts=Counter(num_friends)
10+
xs=range(101)# largest value is 100
11+
ys= [friend_counts[x]forxinxs]# height is just # of friends
12+
plt.bar(xs,ys)
13+
plt.axis([0,101,0,25])
14+
plt.title("Histogram of Friend Counts")
15+
plt.xlabel("# of friends")
16+
plt.ylabel("# of people")
17+
plt.show()
18+
19+
20+
defmain():
21+
friend_hist()
22+
23+
24+
if__name__=='__main__':
25+
main()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp