Javatpoint Logo
Javatpoint Logo

Binomial Distribution in Python

A key idea in probability theory and statistics is the binomial distribution. It explains the likelihood of attaining specific successes in a set number of independent Bernoulli trials, where each trial may only result in success or failure.

Following are the Main Features of the Binomial Distribution:

  • Fixed Number of Trials (n): The binomial distribution deals with a fixed number of trials or experiments, represented by 'n'. Every hardship stands alone from the others.
  • Probability of Success (p): A fixed chance of success, indicated by the letter "p," exists for each trial. The failure probability is thus "1 - p."
  • Independence: It is expected that the trial results are independent. Implies that the result of one trial has no bearing on the outcome of another.
  • The likelihood of achieving precisely 'k' successes in 'n' trials is given by the probability mass function (PMF) of the binomial distribution:
P(X=k) = (nCk) .pk. (1-p)n-k

Where:

  • P(X=k) is the likelihood of achieving precisely 'k' achievements.
  • (nCk) is the binomial coefficient shows how many possible methods there are to choose 'k' successes from 'n' trials.
  • Pk is the likelihood that 'k' will succeed.
  • (1-p)n-k is the likelihood of failures of size 'n - k'.

To obtain distribution we have to import some libraries

Examples 1: Coin Flips

Take a fair coin and toss it ten times. Count how many times it lands heads up. Every flip has two outcomes: heads (success) or tails (failure).

Output:

Binomial Distribution in Python

Example 2: Test pass rates

Each question on a multiple-choice test has four possible answers. A student guesses at random the solutions to a 20-question test. What is the probability that the student will pass if at least ten questions are answered correctly?

Output:

Binomial Distribution in Python

Example 3: Manufacturing Defects

100 products are randomly selected from a production process, and the quantity of faulty goods is tallied. What is the likelihood of discovering precisely 10 faulty goods if the chance of a defective item is 0.1?


Binomial Distribution in Python

Example 4: Online Advertising Click-Through Rates

Consider that you are managing an internet advertising campaign and are aware that historically, your adverts have a click-through rate (CTR) of 0.1 (10%). You want to know the chance of receiving a specific number of clicks out of every 100 impressions while running a new advertisement.


Binomial Distribution in Python

Example 5: Quality Control in Manufacturing

Consider examining 500 light bulbs, of which 5% traditionally exhibit flaws. You need to estimate the likelihood of discovering a specific number of faulty bulbs in the batch.


Binomial Distribution in Python





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA