Binomial Probability
MediumProbabilityMath
Description
Given the number of trials n, a number of successes k, and a success probability p, return the binomial probability of exactly k successes: C(n, k) * p^k * (1 - p)^(n - k). Round the result to 4 decimal places.
Examples
Input:
5, 2, 0.5Output:
0.3125Explanation:
The binomial probability multiplies the number of ways to place k successes by the chance of those successes and of the remaining failures.
Input:
10, 0, 0.3Output:
0.0282Explanation:
The binomial probability multiplies the number of ways to place k successes by the chance of those successes and of the remaining failures.
Input:
4, 2, 0.25Output:
0.2109Explanation:
The binomial probability multiplies the number of ways to place k successes by the chance of those successes and of the remaining failures.
Constraints
- •
0 ≤ k ≤ n ≤ 30 - •
0 ≤ p ≤ 1