From 64a59dafeddd09e39c47f512576371df853bb7ae Mon Sep 17 00:00:00 2001 From: Luisa Balaban <67561596+LuisaBalaban@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:08:01 +0100 Subject: [PATCH] Update 2020-08-26-02-Random-Numbers-and-Probability.ipynb fixed probability calculations to reflect the task demands --- ...26-02-Random-Numbers-and-Probability.ipynb | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/_notebooks/2020-08-26-02-Random-Numbers-and-Probability.ipynb b/_notebooks/2020-08-26-02-Random-Numbers-and-Probability.ipynb index bd9c50969..11e133a54 100644 --- a/_notebooks/2020-08-26-02-Random-Numbers-and-Probability.ipynb +++ b/_notebooks/2020-08-26-02-Random-Numbers-and-Probability.ipynb @@ -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", @@ -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)" ] },