This question is taken from McElreath, R. (2020). Statistical rethinking: A Bayesian course with examples in R and Stan (2. Ed.). Taylor and Francis, CRC Press.
2M3. Suppose there are two globes, one for Earth and one for Mars. The Earth globe is 70% covered in water. The Mars globe is 100% land. Further suppose that one of these globes—you don’t know which—was tossed in the air and produced a “land” observatiion. Assume that each globe was equally likely to be tossed. Show that the posterior probability that the globe was the Earth, conditional on seeing “land” (Pr(Earth|land)), is 0.23.
Lösung
Man kann die Aufgabe entweder mit einer Bayes-Box lösen oder durch die Formel des Bayes’ Theorem.
Bayes-Box
Hyp
Prior
L
Po-unstand
Po-stand
E
1
.3
.3
3/13
M
1
1
1
10/13
Bayes-Theorem
Zur Erinnerung:
\[\begin{aligned}
Pr(A) &= Pr(A \cap B) + Pr(A \cap B^C) \qquad \text{| totale Wskt, bei disjunkten Ereignissen}\\
Pr(A \cap B) &= Pr(A|B) \cdot Pr(B)\\
Pr(A \cap B^C) &= Pr(A|B^C) \cdot Pr(B^C)
\end{aligned}\]
Wobei \(A^C\) das komlementäre Ereignis zu \(A\) meint.
# probability of land, given Earth:p_le <-0.3# probability of land, given Mars:p_lm <-1.0# probability of Earth:p_e <-0.5# prob. of Mars:p_m <-0.5# probability of land:# totale Wahrscheinlichkeit für Landp_l <- (p_e * p_le) + (p_m * p_lm)p_l
[1] 0.65
Dann gilt also:
# probability of Earth, given land (using Bayes' Theorem):p_el <- (p_le * p_e) / p_lp_el
[1] 0.2307692
Einfacher als die Rechnung ist vielleicht ein Baumdiagramm:
Categories:
probability
bayes
rethink-chap2
string
Source Code
---extype: stringexsolution: NAexname: rethink2m3expoints: 1categories:- probability- bayes- rethink-chap2- stringdate: '2023-11-08'slug: Rethink2m3title: Rethink2m3---```{r libs, include = FALSE}library(tidyverse)``````{r global-knitr-options, include=FALSE}knitr::opts_chunk$set(fig.pos = 'H', fig.asp = 0.618, fig.width = 4, fig.cap = "", fig.path = "", message = FALSE, warning = FALSE, out.width = "100%", cache = TRUE)```# AufgabeThis question is taken from McElreath, R. (2020). *Statistical rethinking: A Bayesian course with examples in R and Stan* (2. Ed.). Taylor and Francis, CRC Press.2M3. Suppose there are two globes, one for Earth and one for Mars. The Earth globe is 70% covered in water. The Mars globe is 100% land. Further suppose that one of these globes—you don’t know which—was tossed in the air and produced a “land” observatiion. Assume that each globe was equally likely to be tossed. Show that the posterior probability that the globe was the Earth, conditional on seeing “land” (Pr(Earth|land)), is 0.23.</br></br></br></br></br></br></br></br></br></br># LösungMan kann die Aufgabe entweder mit einer Bayes-Box lösen oder durch die Formel des Bayes' Theorem.# Bayes-Box| Hyp | Prior | L | Po-unstand | Po-stand ||-----|-------|----|------------|-------|| E | 1 | .3 | .3 | 3/13 || M | 1 | 1 | 1 | 10/13 |# Bayes-TheoremZur Erinnerung:$$\begin{aligned}Pr(A) &= Pr(A \cap B) + Pr(A \cap B^C) \qquad \text{| totale Wskt, bei disjunkten Ereignissen}\\Pr(A \cap B) &= Pr(A|B) \cdot Pr(B)\\Pr(A \cap B^C) &= Pr(A|B^C) \cdot Pr(B^C)\end{aligned}$$Wobei $A^C$ das komlementäre Ereignis zu $A$ meint.The solution is taken from [this source](https://sr2-solutions.wjakethompson.com/bayesian-inference.html).```{r}# probability of land, given Earth:p_le <-0.3# probability of land, given Mars:p_lm <-1.0# probability of Earth:p_e <-0.5# prob. of Mars:p_m <-0.5# probability of land:# totale Wahrscheinlichkeit für Landp_l <- (p_e * p_le) + (p_m * p_lm)p_l```Dann gilt also:```{r}# probability of Earth, given land (using Bayes' Theorem):p_el <- (p_le * p_e) / p_lp_el```Einfacher als die Rechnung ist vielleicht ein Baumdiagramm:```{r, echo = FALSE}DiagrammeR::mermaid("graph LR A[Start] -->|1/2|B[Erde] A -->|1/2|C[Mars] B -->|7/10|D[Wasser geg. Erde] B -->|3/10|E[Land geg. Erde] D --- H[Fazit: 7/20] E --- I[Fazit: 3/20] C -->|1|F[Land geg. Mars] C -->|0|G[Wasser geg. Mars] F --- J[Fazit: 1/2] G --- K[Fazit: 0]")```---Categories: - probability- bayes- rethink-chap2- string