I follow the example (how many fish are in the lake?) from silde.
The silde give a simulation about this question
- Catch a couple of fish.
- Mark them and throw them back.
- At a later point, catch a couple of fish again.
- Count how many are marked.
Assume: 20 were marked and five out of the 20 that were caught the second time were marked.
the R code is
library(pacman)
p_load(tidyverse, brms)
pick_fish <- function(n_fish) {
fish <- rep(0:1, c(n_fish - 20, 20))
sum(sample(fish, 20))
}
d <-
tibble(lambda = 30:250) %>%
mutate(prob = dunif(lambda, min = 30, max = 250))
samples <-
tibble(samples = sample(d$lambda, prob = d$prob, size = 1e4, replace = T)) %>%
mutate(n_marked = map(samples, pick_fish)) %>%
unnest(n_marked) %>%
filter(n_marked == 5)
my question is how to figure out above fish re-capture problem using brms?