knitr::opts_chunk$set(echo = TRUE)

library(tidyverse)

create parameter estimators

# set args
mu = 0.7
epsilon = 0.1
alpha <- mu * (
  ((10 * mu^2) / epsilon^2) * 
    (1 / mu - 1) - 1 
)

beta <- alpha / mu - alpha
tibble(x = c(0, 1)) %>% 
  ggplot(aes(x = x)) +
  stat_function(fun = dbeta, args = list(shape1 = alpha, shape2 = beta)) +
  labs(title = paste0(
    "beta distribution with expected centre ",
    mu, 
    " and 90% of values falling within ",
    epsilon
    ))


softloud/metasim documentation built on July 15, 2019, 8:02 p.m.