| Conditions | 1 |
| Total Lines | 9 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | #!/usr/bin/env python3 |
||
| 20 | def bin(trials, population, probability): |
||
| 21 | """ Calculate the probability binomial distribution Pr(X = x) """ |
||
| 22 | # x = trials |
||
| 23 | # n = population |
||
| 24 | # p = probability |
||
| 25 | bern = ((1 - probability)**(population-trials))*probability**trials |
||
| 26 | bincof = factorial(population) / (factorial(trials) * factorial(population - trials)) |
||
| 27 | binpro = bern * bincof |
||
| 28 | return round(binpro, 3) |
||
| 29 | |||
| 39 |