1. Using a generative model
In the last video, we implemented a generative model from scratch, but in the last exercise you realized that that was unnecessary work as this generative model was the same as
2. Binomial distribution function
the binomial distribution function. And it’s actually the case that all probability distributions, like the normal distribution or the Poisson distribution, can be seen as small generative models, and there are many more that are implemented in R. But for now, we’ll stick with the binomial distribution. So, now we have
3. R binom zombie model 1
a generative model, where we can plug in
4. R binom zombie model 2
fixed parameter values and it will
5. R binom zombie model 3
generate simulated data for us. This could be useful if we know exactly what parameter values we want, and we want to
6. R binom zombie model 4
predict what future unknown data might be. Say we are completely sure that our drug cures
7. R binom zombie model 5
7% of all zombies, but we want to know how many we’ll likely cure when we give the drug to the
8. R binom zombie model 6
100 zombies we have in our zombie pit.
9. Binomial model 1
We could then plug in 100 and 0.07 as parameters to rbinom and then run this generative model a large number of times by setting n to, say, 100000.
10. Binomial model 2
The result is a long vector of samples, which now represents the probability distribution over how many zombies we will cure. If we plot it as a histogram using the hist function
11. Binomial model 3
we see that we’ll probably cure between 3 to 12 of the 100 zombies in our pit. Of course, this only makes sense if we are very certain that our drug cures 7% of all zombies.
12. Idea behind Bayesian inference 1
So we can go from known parameters to unknown data, the problem is that in data analysis we are often in the complete opposite situation. We know what the data is, it’s not uncertain, and we want to work our way
13. Idea behind Bayesian inference 2
backward and figure out what are likely the parameter values that generated this data. This is what we are going to use
14. Idea behind Bayesian inference 3
Bayesian inference for. But we can’t do that yet, because, if you remember, we don’t have all the parts we need.
15. Bayes needs this 3
We have defined a generative model, so we can
16. Bayes needs this 4
tick that off, but we still need priors and data. Going forward we are leaving
17. Group of zombies
the zombies behind and will continue our journey towards understanding Bayesian inference with this new, fresh
18. Group of business people
business example. Assume you are running a website and to get
19. You are running a website
more visitors you are going to pay for an ad to be shown on a popular social media site. You are thinking about paying for the ad to be shown a 100 times but you’re uncertain whether it’s worth it,
20. How many visitors?
how many more site visits is it really going to generate? According to the social media site, their ads get clicked on 10% of the time. Let’s start by taking this number at face value and produce a probability distribution over how many visitors you’ll get. The binomial model should work well here too, but instead of how many zombies will get cured, we now want to know how many ads will get clicked.