Hi im coding a homework in mathematica about finding the probability of a program failing, make a plot and a table with the results however Im having trouble getting the last value of the table
Clear[bin1]
bin1[n_, p_, k_] :=
Module[{prob = (1 - p)^n, i},
Do[prob = (((n - i + 1)/i) (p/(1 - p))) prob, {i, k}]; prob]
distribution =
Table[bin1[50, #, k], {k, 0, 50}] & /@ Range[0, .9, .1];
thats the probability calculator
prob = Max[Take[distribution, {#}]] & /@ Range[1, 10] thats to take the first value of the table (its the porcentage of failiure)
position = # & /@ Range[0, .9, .1](thats just for the third value)
max = Last[
Last[Position[distribution, Take[prob {#}] & /@ Range[1, 10]]]]
thats the third value and where i have trouble its supossed to be tha maximum value but the prob{#} part doesnt work i have no idea why
The final table should be: TableForm[{position, prob, max}]
Take. That said you dont need to use take at all.Max[Take[distribution, {#}]] & /@ Range[1, 10]can be simply written asMax /@ distribution- agentp