Xerobit

Binomial Distribution Calculator: Probability of Exactly k Successes

Enter the number of trials, the target number of successes, and the probability of success on each trial to find the exact binomial probability. This binomial distribution calculator computes P(X = k) instantly in your browser without uploading any data.

Result

  • P(X = 3)
    0.1171875

    Probability of exactly k successes

  • C(n, k)
    120

    Binomial coefficient (combinations)

  • Mean (np)
    5
  • Variance (npq)
    2.5
  • Std deviation
    1.58113883008

How to use the binomial distribution calculator

  1. Enter the total number of independent trials n.
  2. Enter the desired number of successes k (must be less than or equal to n).
  3. Enter the probability of success on a single trial p as a decimal from 0 to 1.
  4. The binomial distribution calculator updates automatically to show P(X = k), the combination count, and the mean and variance.

How the Binomial Formula Works

The binomial distribution gives the probability of observing exactly k successes in n independent trials, where each trial has the same probability of success p. The formula is:

P(X = k) = C(n, k) * p^k * (1 - p)^(n - k)

Here, C(n, k) is the binomial coefficient, calculated as n! / (k! * (n - k)!). For example, if you flip a fair coin 10 times and want exactly 3 heads: C(10, 3) = 120, p^3 = 0.5^3 = 0.125, and (1-p)^7 = 0.5^7 = 0.0078125. Multiplying these together gives 120 * 0.125 * 0.0078125 = 0.1171875.

Conditions for a Binomial Experiment

Not every probability problem fits the binomial model. A scenario qualifies only when four conditions are met:

  • Fixed number of trials: You decide in advance how many times the experiment runs (n).
  • Two outcomes per trial: Each trial results in either a success or a failure.
  • Constant probability: The chance of success (p) stays the same for every trial.
  • Independence: The outcome of one trial does not affect any other trial.

Drawing cards without replacement violates the constant probability rule, so it requires a hypergeometric model instead. Drawing with replacement keeps the probability fixed and fits the binomial distribution perfectly.

Mean, Variance, and Standard Deviation

Beyond the probability of a specific outcome, the binomial distribution has well-defined summary statistics. The expected value (mean) is simply n * p. If you roll a fair die 60 times looking for sixes, the expected number of sixes is 60 * (1/6) = 10.

The variance measures how spread out the results tend to be and is computed as n * p * (1 - p). The standard deviation is the square root of the variance. These values help you judge whether an observed result is typical or unusual. For large sample sizes, the binomial distribution closely resembles a normal curve centered on the mean, which connects it to tools like the z score calculator.

Common Binomial Probabilities Reference

This table shows exact probabilities for common scenarios using a fair coin (p = 0.5).

Trials (n)Successes (k)P(X = k)
500.03125
510.15625
520.3125
530.3125
1050.24609375
10100.0009765625
20100.176197052

Notice that getting exactly half heads becomes less likely as the number of flips increases, even though the proportion remains centered at 0.5.

Numerical Stability for Large Trials

When n is large, computing factorials directly causes overflow because numbers like 170! exceed the maximum safe floating-point value. A robust binomial distribution calculator avoids this by working in logarithmic space. Instead of multiplying huge numbers, it sums their natural logs:

ln(P) = ln(C(n,k)) + k*ln(p) + (n-k)*ln(1-p)

The final probability is then e^(ln(P)). This approach keeps intermediate values small and prevents rounding errors. It also handles edge cases gracefully: when p is 0 or 1, the formula simplifies immediately without attempting to take the logarithm of zero.

Worked examples

Each result below was produced by the same code the tool runs, so you can check your own numbers against them.

ExampleInputResult
Coin flips: 3 heads in 10 tossesNumber of trials (n): 10; Number of successes (k): 3; Probability of success (p): 0.5P(X = 3): 0.1171875; C(n, k): 120; Mean (np): 5; Variance (npq): 2.5; Std deviation: 1.58113883008
Quality control: 0 defects in 20 itemsNumber of trials (n): 20; Number of successes (k): 0; Probability of success (p): 0.02P(X = 0): 0.667607971755; C(n, k): 1; Mean (np): 0.4; Variance (npq): 0.392; Std deviation: 0.6260990337
Free throws: 8 makes out of 10Number of trials (n): 10; Number of successes (k): 8; Probability of success (p): 0.75P(X = 8): 0.281567573547; C(n, k): 45; Mean (np): 7.5; Variance (npq): 1.875; Std deviation: 1.36930639376
Survey responses: 50 yes out of 100Number of trials (n): 100; Number of successes (k): 50; Probability of success (p): 0.4P(X = 50): 0.0103375112538; C(n, k): 1.008913e+29; Mean (np): 40; Variance (npq): 24; Std deviation: 4.89897948557

FAQ

What is the difference between binomial and Bernoulli distributions?

A Bernoulli distribution describes a single trial with two outcomes, while a binomial distribution describes the total number of successes across multiple independent Bernoulli trials. Setting n = 1 in this binomial distribution calculator gives you the Bernoulli probability.

Can I use this for cumulative probabilities like P(X <= k)?

This tool calculates the probability of exactly k successes. To find P(X <= k), you would sum the individual probabilities for 0, 1, 2, up to k. Many statistical software packages provide a built-in cumulative function for this purpose.

Why does my probability come out as zero for very large n?

When n is very large and k is far from the mean, the true probability can be smaller than the smallest number JavaScript can represent (about 10^-308). In such cases, the result underflows to zero. Working in log space helps, but extremely tiny probabilities still round down.

Does the order of successes matter?

No. The binomial coefficient C(n, k) accounts for all possible arrangements of k successes among n trials. You are counting combinations, not permutations.

Is my data sent to a server when I use this tool?

No. All calculations happen locally in your browser. Nothing you type into the binomial distribution calculator is uploaded anywhere.

What happens if p is exactly 0 or 1?

If p = 0, the probability of any success is zero unless k = 0, in which case P = 1. If p = 1, every trial succeeds, so P = 1 only when k = n. The calculator handles both boundary cases correctly.