You have a box of tacks for which it has been determined that if you toss them on the floor precisely 36% will land point up.
How many of these tacks could you toss to make the most likely result be that 10 of them will land point up.
Python program:
from math import factorial
a = .36
nmax = 40
heads = [0 for k in range(nmax)]
for n in range(nmax):
heads[n] = [0 for j in range(n+1)]
for i in range(n+1):
comb = (factorial(n) / (factorial(i) * factorial(n-i)))
heads[n][i] = comb * a**i * (1-a)**(n-i)
if i == 0:
max_prob = 0
maxi = 0
else:
if heads[n][i] > heads[n][i-1]:
max_prob = heads[n][i]
maxi = i
elif heads[n][i] == heads[n][i-1]:
print('tie:', i-1,i)
print(n,maxi)
Outputs the following:
0 0
1 0
2 1
3 1
4 1
5 2
6 2
7 2
8 3
9 3
10 3
11 4
12 4
13 5
14 5
15 5
16 6
17 6
18 6
19 7
20 7
21 7
22 8
23 8
24 8
25 9
26 9
27 10
28 10
29 10
30 11
31 11
32 11
33 12
34 12
35 12
36 13
37 13
38 14
39 14
|
Posted by Larry
on 2020-01-15 09:16:14 |