Plotting Binomial Distribution


Here, we will use R to plot a binomial distribution. For a given n and p, we use the command dbinom to produce a range of binomial probabilities from to n (in R, a range of integers from a tp b, inclusively, is defined using a:b). We then use the plot command to automatically produce a scatter plot of the probabilities.

Sage Cell


n = 40
p = 0.50
plot(x=0:n, y=dbinom(0:n, n, p))


Plotting probabilities as ln(p)

By setting the log property to TRUE, we can plot probability p as ln(p).


n = 40
p = 0.50
plot(x=0:n, y=dbinom(0:n, n, p, log = TRUE))


Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.




Date: 16 Apr 2019 16:13

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License