## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  warning = FALSE,
  fig.width = 7,
  fig.height = 4.5,
  out.width = "100%"
)

## ----setup--------------------------------------------------------------------
library(ambre)
set.seed(2024)

## ----exposure-control---------------------------------------------------------
config_ambre$exposure[, c("name", "type", "value", "min", "max")]

## ----crd----------------------------------------------------------------------
draw <- create_random_distribution(
  type = "uniform",
  number_of_repeatings = 3,
  number_of_events = 5,
  min = 1, max = 10,
  debug = FALSE
)
head(draw$events)
draw$paras

## ----grv----------------------------------------------------------------------
vol_row <- config_ambre$exposure[config_ambre$exposure$name == "volume_perEvent", ]
gv <- generate_random_values(
  vol_row,
  number_of_repeatings = 2,
  number_of_events = 4,
  debug = FALSE
)
summary(gv$events$volume_perEvent)

## ----percentile---------------------------------------------------------------
ambre:::get_percentile(0.9)

## ----triangle-collapse--------------------------------------------------------
degenerate <- data.frame(
  type = "triangle", value = NA,
  min = 2, max = 2, mode = NA,
  mean = NA, sd = NA, meanlog = NA, sdlog = NA
)
gv2 <- generate_random_values(degenerate, number_of_repeatings = 1,
                              number_of_events = 3, debug = FALSE)
unique(gv2$events$values)

## ----seed---------------------------------------------------------------------
set.seed(1)
a <- create_random_distribution(type = "uniform", number_of_repeatings = 1,
                                number_of_events = 4, min = 0, max = 1, debug = FALSE)
set.seed(1)
b <- create_random_distribution(type = "uniform", number_of_repeatings = 1,
                                number_of_events = 4, min = 0, max = 1, debug = FALSE)
identical(a$events$values, b$events$values)

