Skip to content

Commit 9ace409

Browse files
committed
Update py_exploratory_comp_9_sol.ipynb
pole -> poll (-:
1 parent 3319676 commit 9ace409

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

notebook9_discrete_random_variables/py_exploratory_comp_9_sol.ipynb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
{
4949
"data": {
5050
"text/plain": [
51-
"array([0, 1, 1, 1, 0, 1, 0, 1, 1, 0])"
51+
"array([1, 1, 0, 1, 0, 0, 0, 1, 1, 1])"
5252
]
5353
},
5454
"execution_count": 2,
@@ -75,7 +75,7 @@
7575
{
7676
"data": {
7777
"text/plain": [
78-
"array([0, 1, 0, 1, 0, 0, 1, 1, 1, 0])"
78+
"array([1, 0, 0, 0, 1, 1, 1, 1, 1, 1])"
7979
]
8080
},
8181
"execution_count": 3,
@@ -585,7 +585,7 @@
585585
"metadata": {},
586586
"source": [
587587
"### Exercise 6. <a name=\"back6\"></a>Election poll\n",
588-
"Consider an election where one million people will vote. 490,000 people will vote for candidate $A$ and 510,000 people will vote for candidate $B$. One day before the election, the company of 'Maurice the Dog' conducts a pole among 1000 randomly chosen voters. Compute whether the Dog will predict the winner correctly using the approach explained above and a seed of 2."
588+
"Consider an election where one million people will vote. 490,000 people will vote for candidate $A$ and 510,000 people will vote for candidate $B$. One day before the election, the company of 'Maurice the Dog' conducts a poll among 1000 randomly chosen voters. Compute whether the Dog will predict the winner correctly using the approach explained above and a seed of 2."
589589
]
590590
},
591591
{
@@ -599,7 +599,7 @@
599599
"cell_type": "markdown",
600600
"metadata": {},
601601
"source": [
602-
"Perform the pole 1000 times. Count how many times the outcome of the pole is that candidate $A$ wins and how many times the outcome of the pole is that candidate $B$ wins. What is the probability that the Dog will predict the correct winner based on these 1000 poles of 1000 people? "
602+
"Perform the poll 1000 times. Count how many times the outcome of the poll is that candidate $A$ wins and how many times the outcome of the poll is that candidate $B$ wins. What is the probability that the Dog will predict the correct winner based on these 1000 polls of 1000 people? "
603603
]
604604
},
605605
{
@@ -613,7 +613,7 @@
613613
"cell_type": "markdown",
614614
"metadata": {},
615615
"source": [
616-
"Compute the probability that the Dog will predict the correct winner based on 1000 poles of 5000 people. Does the probability that The Dog predicts the correct winner increase significantly when he poles 5000 people?"
616+
"Compute the probability that the Dog will predict the correct winner based on 1000 polls of 5000 people. Does the probability that The Dog predicts the correct winner increase significantly when he polls 5000 people?"
617617
]
618618
},
619619
{
@@ -886,7 +886,7 @@
886886
"name": "stdout",
887887
"output_type": "stream",
888888
"text": [
889-
"poled for A: 508\n",
889+
"polled for A: 508\n",
890890
"The Dog will predict the wrong winner\n"
891891
]
892892
}
@@ -895,10 +895,10 @@
895895
"rnd.seed(2)\n",
896896
"people = np.zeros(1000000, dtype='int') # candidate A is 0\n",
897897
"people[490000:] = 1 # candidate B is 1\n",
898-
"pole = rnd.choice(people, 1000)\n",
899-
"poled_for_A = np.count_nonzero(pole == 0)\n",
900-
"print('poled for A:', poled_for_A)\n",
901-
"if poled_for_A > 500: \n",
898+
"poll = rnd.choice(people, 1000)\n",
899+
"polled_for_A = np.count_nonzero(poll == 0)\n",
900+
"print('polled for A:', polled_for_A)\n",
901+
"if polled_for_A > 500: \n",
902902
" print('The Dog will predict the wrong winner')\n",
903903
"else:\n",
904904
" print('The Dog will predict the correct winner')"
@@ -913,7 +913,7 @@
913913
"name": "stdout",
914914
"output_type": "stream",
915915
"text": [
916-
"1000 poles of 1000 people\n",
916+
"1000 polls of 1000 people\n",
917917
"Probability that The Dog predicts candidate A to win: 0.267\n"
918918
]
919919
}
@@ -924,13 +924,13 @@
924924
"for i in range(1000):\n",
925925
" people = np.zeros(1000000, dtype='int') # candidate A is 0\n",
926926
" people[490000:] = 1 # candidate B is 1\n",
927-
" pole = rnd.choice(people, 1000)\n",
928-
" poled_for_A = np.count_nonzero(pole == 0)\n",
929-
" if poled_for_A > 500: \n",
927+
" poll = rnd.choice(people, 1000)\n",
928+
" polled_for_A = np.count_nonzero(poll == 0)\n",
929+
" if polled_for_A > 500: \n",
930930
" Awins += 1\n",
931931
" else:\n",
932932
" Bwins += 1\n",
933-
"print('1000 poles of 1000 people')\n",
933+
"print('1000 polls of 1000 people')\n",
934934
"print('Probability that The Dog predicts candidate A to win:', Awins / 1000)"
935935
]
936936
},
@@ -943,7 +943,7 @@
943943
"name": "stdout",
944944
"output_type": "stream",
945945
"text": [
946-
"1000 poles of 5000 people\n",
946+
"1000 polls of 5000 people\n",
947947
"Probability that The Dog predicts candidate A to win: 0.07\n"
948948
]
949949
}
@@ -954,13 +954,13 @@
954954
"for i in range(1000):\n",
955955
" people = np.zeros(1000000, dtype='int') # candidate A is 0\n",
956956
" people[490000:] = 1 # candidate B is 1\n",
957-
" pole = rnd.choice(people, 5000)\n",
958-
" poled_for_A = np.count_nonzero(pole == 0)\n",
959-
" if poled_for_A > 2500: \n",
957+
" poll = rnd.choice(people, 5000)\n",
958+
" polled_for_A = np.count_nonzero(poll == 0)\n",
959+
" if polled_for_A > 2500: \n",
960960
" Awins += 1\n",
961961
" else:\n",
962962
" Bwins += 1\n",
963-
"print('1000 poles of 5000 people')\n",
963+
"print('1000 polls of 5000 people')\n",
964964
"print('Probability that The Dog predicts candidate A to win:', Awins / 1000)"
965965
]
966966
},

0 commit comments

Comments
 (0)