Bayesian Problems
Last Update: 2021-03-25
1 Overview of Bayesian Inference
1. Run the following examples in R. Compare the plots produced and comment the big idea(s) illustrated by this comparison.
library(CalvinBayes)
library(patchwork)
BernGrid("H", resolution = 4, prior = triangle::dtriangle) /
BernGrid("H", resolution = 10, prior = triangle::dtriangle) |
BernGrid("H", prior = 1, resolution = 100, geom = geom_col) /
BernGrid("H", resolution = 100,
prior = function(p) abs(p - 0.5) > 0.48, geom = geom_col)
2. Run the following examples in R. Compare the plots produced and comment the big idea(s) illustrated by this comparison.
library(CalvinBayes)
BernGrid("TTHT", prior = triangle::dtriangle) |
BernGrid("TTHT", prior = function(x) triangle::dtriangle(x)^0.3) |
BernGrid("TTHT", prior = function(x) triangle::dtriangle(x)^3)
3. Run the following examples in R. Compare the plots produced and comment the big idea(s) illustrated by this comparison.
library(CalvinBayes)
<- function(p) {
dfoo 0.02 * dunif(p) +
0.49 * triangle::dtriangle(p, 0.0, 0.2) +
0.49 * triangle::dtriangle(p, 0.8, 1.0)
}BernGrid(c(rep(0,10), rep(1,9)), prior = triangle::dtriangle) |
BernGrid(c(rep(0,10), rep(1,9)), prior = dfoo)
4. Run the following examples in R. Compare the plots produced and comment the big idea(s) illustrated by this comparison.
library(CalvinBayes)
BernGrid(rep(0,5),
prior = ~triangle::dtriangle(.x, 0, 1, 1)^3) |
BernGrid(rep(0,10),
prior = ~triangle::dtriangle(.x, 0, 1, 1)^3) |
BernGrid(rep(0,30),
prior = ~triangle::dtriangle(.x, 0, 1, 1)^3)
5. Run the following examples in R. Compare the plots produced and comment the big idea(s) illusrated by this comparison.
library(CalvinBayes)
<- function(p) {
dfoo 0.02 * dunif(p) +
0.49 * triangle::dtriangle(p, 0.1, 0.2) +
0.49 * triangle::dtriangle(p, 0.8, 0.9)
}BernGrid(c(rep(0, 3), rep(1, 3)), prior = dfoo) /
BernGrid(c(rep(0, 10), rep(1, 10)), prior = dfoo) |
BernGrid(c(rep(0, 30), rep(1, 30)), prior = dfoo) /
BernGrid(c(rep(0, 100), rep(1, 100)), prior = dfoo)
6. Run the following examples in R and compare them to the ones in the previous exercise. What do you observe?
library(CalvinBayes)
<- function(p) {
dfoo 0.02 * dunif(p) +
0.49 * triangle::dtriangle(p, 0.1, 0.2) +
0.49 * triangle::dtriangle(p, 0.8, 0.9)
}BernGrid(c(rep(0, 3), rep(1, 4)), prior = dfoo) /
BernGrid(c(rep(0, 10), rep(1, 11)), prior = dfoo) /
BernGrid(c(rep(0, 30), rep(1, 31)), prior = dfoo) |
BernGrid(c(rep(0, 4), rep(1, 3)), prior = dfoo) /
BernGrid(c(rep(0, 11), rep(1, 10)), prior = dfoo) /
BernGrid(c(rep(0, 31), rep(1, 30)), prior = dfoo)