``````library(here)
library(tidyverse)
library(ggplot2)``````

This notebook gives a simple example of Bayesian inference.

## Coughing Patient

Suppose that you work in a doctor’s office and you meet a woman called Jen who is sitting in the waiting room. You start thinking about what condition she might have. To keep things simple, let’s assume that there are only three possible hypotheses \(h\): either she has a `cold`, or she has `emphysema`, or she has a `stomach upset`. Your prior distribution \(P(h)\) over these hypotheses captures your expectations about which hypothesis is true before you have gathered any additional evidence. Let’s assume that the prior plotted below captures your beliefs. As set up initially, the prior captures the idea that `cold` and `stomach upset` are both more likely than `emphysema`.

``````h  <- c('cold', 'emphysema', 'stomach upset')
p_h <- c(0.46, 0.04, 0.5)
prior <- tibble(h, val=p_h, dist='prior P(h)')

plotdiseasechart <- function(d) {
pic <- d %>%
ggplot(aes(x=h, y = val)) +
scale_y_continuous(lim=c(0,1)) +
geom_col() +
facet_grid(dist ~ .)  +
xlab("hypothesis")
plot(pic)
}

plotdiseasechart(prior)``````