dbinom function

This function returns the value of the probability density function (pdf) of the binomial distribution given a certain random variable x, number of trials (size), and probability of success on each trial (prob). 

Syntax: dbinom(x, size, prob)

Parameters:

  • x : a vector of numbers.
  • size : the number of trials.
  • prob : the probability of success of each trial.

The dbinom function is also used to get the probability of getting a certain number of successes (x) in a certain number of trials (size) where the probability of success on each trial is fixed (prob).

Example 1:

Here, we are using the example to the binomial distribution to find the probability where a person makes 70% of his throw attempts, and if he shoots 20 throws, so what will be the probability that the person makes exactly 12 of them attempt, so here we are simply using the dbinom function and passing the given statements properties as its parameters and further getting the result in the R. function

R




dbinom(x=12, size=20, prob=.7)


Output:

[1] 0.1143967

Example 2:

In this example, we are simply calculating the probability to get the heads exactly 17 times if the coin is tossed 50 times fairly using the dbinom function. Since the coin is tossed fairly the prob parameter to the function is passed to be 0.5. 

R




dbinom(x=17, size=50, prob=.5)


Output:

[1] 0.00874623

A Guide to dbinom, pbinom, qbinom, and rbinom in R

In this article, we will be looking at a guide to the dbinom, pbinom, qbinom, and rbinom methods of the binomial distribution in the R programming language.

Similar Reads

dbinom function

This function returns the value of the probability density function (pdf) of the binomial distribution given a certain random variable x, number of trials (size), and probability of success on each trial (prob)....

pbinom function

...

qbinom function

...

rbinom function

This function returns the value of the cumulative density function (cdf) of the binomial distribution given a certain random variable q, number of trials (size), and probability of success on each trial (prob)....

Contact Us