Binomial Probability Distribution Using R
Experiment
Binomial Probability Distribution Using R
1. Aim
To study and implement the Binomial probability distribution in R by calculating individual and cumulative probabilities, generating the probability distribution, finding its mean and variance, and visualizing the distribution.
2. Objectives
After completing this experiment, students should be able to:
- Understand the concept and characteristics of the Binomial distribution.
- Identify the parameters , , and .
- Calculate binomial probabilities manually using the mathematical formula.
- Calculate probabilities using R.
- Generate the complete binomial probability distribution.
- Calculate the mean, variance, and standard deviation.
- Visualize and interpret the binomial distribution.
3. Theory
3.1 Binomial Distribution
The Binomial distribution is a discrete probability distribution that describes the number of successes obtained in a fixed number of independent trials.
A random experiment follows a Binomial distribution when:
- The number of trials is fixed.
- Each trial has only two possible outcomes: success or failure.
- The probability of success is constant for every trial.
- The trials are independent.
If represents the number of successes in trials, then:
where:
- = number of trials
- = probability of success
- = probability of failure
- = number of successes
3.2 Binomial Probability Formula
The probability of obtaining exactly successes in trials is:
where
Therefore,
3.3 Manual Calculation for the Given Problem
Consider the experiment:
A company produces electronic components. The probability that a component is defective is 0.10. If 10 components are selected independently, find the probability of exactly 2 defective components.
Here:
and
Therefore:
First calculate the binomial coefficient:
Therefore:
Hence,
or approximately:
3.4 Manual Calculation of Cumulative Probability
Probability of at most 2 defective components
"At most 2" means:
Therefore:
For :
For :
For :
Therefore:
or approximately 92.98%.
3.5 Probability of At Least 2 Defective Components
"At least 2" means:
It is easier to use the complement:
Since:
we get:
Note: This is the value for the given interpretation of "at least 2." In R, it can be calculated as 1 - pbinom(1, 10, 0.1).
3.6 Mean of Binomial Distribution
The mean or expected value of a Binomial distribution is:
For the given problem:
Thus, the expected number of defective components in 10 components is 1.
3.7 Variance of Binomial Distribution
The variance is:
Since:
we get:
3.8 Standard Deviation
The standard deviation is:
Therefore:
3.9 R Functions for Binomial Distribution
R provides four important functions:
| Function | Meaning |
|---|---|
dbinom(x,n,p) | , exactly successes |
pbinom(x,n,p) | , at most successes |
qbinom() | Finds the value of for a given cumulative probability |
rbinom() | Generates random observations from a Binomial distribution |
4. Program
# Binomial Probability Distribution # Parameters n <- 10 p <- 0.10 q <- 1 - p # Possible number of defective components x <- 0:n # Probability distribution probability <- dbinom(x, size = n, prob = p) # Display probability distribution distribution <- data.frame( Defective = x, Probability = probability ) print(distribution) # Probability of exactly 2 defective components p_exactly_2 <- dbinom(2, size = n, prob = p) cat("\nProbability of exactly 2 defective components =", p_exactly_2, "\n") # Probability of at most 2 defective components p_at_most_2 <- pbinom(2, size = n, prob = p) cat("Probability of at most 2 defective components =", p_at_most_2, "\n") # Probability of at least 2 defective components p_at_least_2 <- 1 - pbinom(1, size = n, prob = p) cat("Probability of at least 2 defective components =", p_at_least_2, "\n") # Mean mean_value <- n * p # Variance variance <- n * p * q # Standard deviation standard_deviation <- sqrt(variance) cat("\nMean =", mean_value, "\n") cat("Variance =", variance, "\n") cat("Standard Deviation =", standard_deviation, "\n") # Plot the Binomial distribution barplot(probability, names.arg = x, main = "Binomial Probability Distribution", xlab = "Number of Defective Components", ylab = "Probability")
5. Expected Result
The program produces the binomial probability distribution for .
Important results are:
Defective Probability 1 0 0.3486784401 2 1 0.3874204890 3 2 0.1937102445 4 3 0.0573956280 5 4 0.0111602610 6 5 0.0014880348 7 6 0.0001377810 8 7 0.0000087480 9 8 0.0000003645 10 9 0.0000000090 11 10 0.0000000001 Probability of exactly 2 defective components = 0.1937102 Probability of at most 2 defective components = 0.9298092 Probability of at least 2 defective components = 0.2639011 Mean = 1 Variance = 0.9 Standard Deviation = 0.9486833
The bar plot represents the probability associated with each possible number of defective components.
6. Result
Thus, the Binomial probability distribution was studied and implemented in R. The probability of exactly 2, at most 2, and at least 2 defective components was calculated. The complete probability distribution was generated and represented graphically. The mean, variance, and standard deviation were also calculated using the standard Binomial distribution formulas and verified using R.
Comments
Post a Comment