Skip to content

Commit

Permalink
Merge pull request #96 from LuisaBalaban/patch-1
Browse files Browse the repository at this point in the history
Update 2020-08-26-02-Random-Numbers-and-Probability.ipynb
  • Loading branch information
goodboychan authored Jan 10, 2024
2 parents d4f55f3 + 64a59da commit be9a8f7
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions _notebooks/2020-08-26-02-Random-Numbers-and-Probability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -392,24 +392,18 @@
"output_type": "stream",
"text": [
" group_size prob\n",
"0 0 0.2\n",
"1 1 0.4\n",
"2 2 0.6\n",
"3 3 0.2\n",
"4 4 0.2\n",
"5 5 0.2\n",
"6 6 0.3\n",
"7 7 0.2\n",
"8 8 0.4\n",
"9 9 0.2\n",
"12.200000000000001\n",
"1.4999999999999998\n"
"0 2 0.6\n",
"1 4 0.2\n",
"2 6 0.1\n",
"3 3 0.1\n",
"0.30000000000000004\n",
"0.15000000000000002\n"
]
}
],
"source": [
"# Create probability distribution\n",
"size_dist = restaurant_groups['group_size'] / restaurant_groups.shape[0]\n",
"size_dist = restaurant_groups['group_size'].value_counts() / restaurant_groups['group_size'].shape[0]\n",
"\n",
"# Reset index and rename columns\n",
"size_dist = size_dist.reset_index()\n",
Expand All @@ -425,7 +419,7 @@
"groups_4_or_more = size_dist[size_dist['group_size'] >= 4]\n",
"\n",
"# Sum the probabilities of groups_4_or_more\n",
"prob_4_or_more = groups_4_or_more['prob'].sum()\n",
"prob_4_or_more = groups_4_or_more['prob'].sum()/groups_4_or_more.shape[0]\n",
"print(prob_4_or_more)"
]
},
Expand Down

0 comments on commit be9a8f7

Please sign in to comment.