1. Learn
  2. /
  3. Courses
  4. /
  5. Fundamentals of Bayesian Data Analysis in R

Exercise

From rbinom to dbinom

To the right is currently code that

  1. Simulates the number of clicks/visitors (n_clicks) from 100 shown ads using the rbinom function given that the underlying proportion of clicks is 10%.
  2. Calculates the probability of getting 13 visitors (prob_13_visitors).

That is, in probability notation it's calculating P(n_visitors = 13 | proportion_clicks = 10%).

Instructions

100 XP
  • First, try running this code.
  • Then, rewrite this code so that it calculates prob_13_visitors using dbinom instead.

Remember: dbinom directly returns a probability and takes the following arguments: dbinom(x = , size = , prob = ) where size and prob are the same as for rbinom, but x is now the data you want to calculate the probability for.