The binomial distribution is also known as discrete probability distribution, which is used to find the probability of success of an event. The event has only two possible outcomes in a series of experiments. The tossing of the coin is the best example of the binomial distribution. When a coin is tossed, it gives either a head or a tail. The probability of finding exactly three heads in repeatedly tossing the coin ten times is approximate during the binomial distribution.
R allows us to create binomial distribution by providing the following function:
These function can have the following parameters:
Let's start understanding how these functions are used with the help of the examples
dbinom(): Direct Look-Up, Points
The dbinom() function of R calculates the probability density distribution at each point. In simple words, it calculates the density function of the particular binomial distribution.
pbinom():Direct Look-Up, Intervals
The dbinom() function of R calculates the cumulative probability(a single value representing the probability) of an event. In simple words, it calculates the cumulative distribution function of the particular binomial distribution.
qbinom(): Inverse Look-Up
The qbinom() function of R takes the probability value and generates a number whose cumulative value matches with the probability value. In simple words, it calculates the inverse cumulative distribution function of the binomial distribution.
Let's find the number of heads that have a probability of 0.45 when a coin is tossed 51 times.
The rbinom() function of R is used to generate required number of random values for given probability from a given sample.
Let's see an example in which we find nine random values from a sample of 160 with a probability of 0.5.