the fish capture re-capture problem using brms?

I follow the example (how many fish are in the lake?) from silde.

The silde give a simulation about this question

  1. Catch a couple of fish.
  2. Mark them and throw them back.
  3. At a later point, catch a couple of fish again.
  4. 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?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.