# How to create a plot of binomial distribution in R?

R ProgrammingServer Side ProgrammingProgramming

#### Artificial Intelligence : The Future Of Programming

15 Lectures 54 mins

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### C Programming from scratch- Master C Programming

Best Seller

60 Lectures 8 hours

A binomial distribution is based on the distribution of success and failure, the other two parameters of binomial distribution are the sample size and the probability of success. To create a plot of binomial distribution, we first need to define the density of the binomial distribution using dbinom function. The plotting can be done by using plot function with success and the density as shown in the below examples.

## Example

x<-dbinom(0:25,size=10,prob=0.5)
plot(0:25,x,type="h")

## Example

y<-dbinom(0:25,size=20,prob=0.5)
plot(0:25,y,type="h")

## Output

Updated on 08-Feb-2021 06:24:09