% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/create_random_distribution.R
\name{create_random_distribution}
\alias{create_random_distribution}
\title{Create random distribution}
\usage{
create_random_distribution(
  type = "uniform",
  number_of_repeatings = 1,
  number_of_events = 365,
  value = 10,
  min = 10,
  max = 1000,
  percent_within_minmax = 0.9,
  min_zero = 0.01,
  log10_min = default_min(min, max, min_zero, f = log10),
  log10_max = default_max(max, min_zero * 10, f = log10),
  log10_mean = (log10_min + log10_max)/2,
  log10_sdev = abs((log10_max - log10_mean)/get_percentile(percent_within_minmax)),
  mean = (default_min(min, max, min_zero) + default_max(max, 10 * min_zero))/2,
  sdev = abs((default_max(max, 10 * min_zero) -
    mean)/get_percentile(percent_within_minmax)),
  meanlog = mean(log(default_min(min, max, min_zero) + default_max(max, 10 *
    min_zero))/2),
  sdlog = abs(sd(c(default_min(min, max, min_zero, f = log), default_max(max, 10 *
    min_zero, f = log)))),
  mode = (default_min(min, max, min_zero) + default_max(max, 10 * min_zero))/2,
  debug = TRUE
)
}
\arguments{
\item{type}{"uniform" calls runif(), "log10_uniform" calls
10^runif(number_of_events, log10_min, log10_max), "triangle" calls
EnvStats::rtri(), "lognorm" calls rlnorm(), "norm" calls rnorm() and
"log10_norm" calls 10^rnorm(number_of_events, mean = log10_mean,
sdev = log10_sdev), (default: "uniform")}

\item{number_of_repeatings}{how often should the random distribution with the
same parameters be generated (default: 1)}

\item{number_of_events}{number of events}

\item{value}{constant value (no random number), gets repeated number_of_events
times (if 'type' = 'value')}

\item{min}{minimum value (default: 10), only used if 'type' is "runif" or
"triangle"}

\item{max}{maximum value (default: 1000), only used if 'type' is "runif" or
"triangle"}

\item{percent_within_minmax}{percent of data point within min/max (default:
0.9 i.e. 90 percent}

\item{min_zero}{only used if 'type' is "log10_uniform" or
"log10_norm", "norm" or "lognorm" and "min" value equal zero.
In this case the zero is replaced by this value (default: 0.01), see also
\code{default_min()}}

\item{log10_min}{minimum value (default: default_min(min, max,
min_zero, f = log10)), only used if 'type' is "log10_uniform" or "log10_norm"}

\item{log10_max}{maximum value (default: ifelse(max > 0, log10(max),
log10_zero_threshold), only used if 'type' is "log10_uniform" or "log10_norm"}

\item{log10_mean}{mean value (default: (log10_min + log10_max)/2), only used
if 'type' is "log10_norm"}

\item{log10_sdev}{standard deviation (default: abs((log10_max- log10_mean) /
get_percentile(0.95)), only used if 'type' is "log10_norm"}

\item{mean}{mean value (default: (default_min(min, max, min_zero) /
default_max(max, 10*min_zero)) / 2), only used if 'type' is "norm"}

\item{sdev}{standard deviation (default: abs((default_max(max, 10*min_zero) -
mean) / get_percentile(0.95))), only used if 'type' is "norm"}

\item{meanlog}{log mean value (default: mean(log((min + max) / 2))), only
used if 'type' is "lognorm"}

\item{sdlog}{standard deviation (default: abs(sd(c(default_min(min, max,
min_zero, f = log)))) ), only used if 'type' is "lognorm"}

\item{mode}{(default: default_min(min, max, min_zero) +
default_max(max, 10 * min_zero) / 2), only used if 'type' is "triangle"}

\item{debug}{print debug information (default: TRUE)}
}
\value{
list with parameters of user defined random distribution and
corresponding values
}
\description{
This function does the same thing as kwb.utils::create_random_distribution(),
but it is bundled with \emph{ambre} to avoid a hard dependency on the
unmaintained package.
}
\examples{

# Example usage of create_random_distribution
# Uniform distribution
uniform_dist <- create_random_distribution(
  type = "uniform",
  number_of_repeatings = 2,
  number_of_events = 10,
  min = 0,
  max = 100
)

# Log10 uniform distribution
log10_uniform_dist <- create_random_distribution(
  type = "log10_uniform",
  number_of_events = 10,
  min = 1,
  max = 1000
)

# Triangle distribution
triangle_dist <- create_random_distribution(
  type = "triangle",
  number_of_events = 10,
  min = 0,
  max = 100,
  mode = 50
)

# Normal distribution
norm_dist <- create_random_distribution(
  type = "norm",
  number_of_events = 10,
  mean = 50,
  sdev = 10
)

# Log10 normal distribution
log10_norm_dist <- create_random_distribution(
  type = "log10_norm",
  number_of_events = 10,
  log10_mean = 2,
  log10_sdev = 0.5
)

# Lognormal distribution
lognorm_dist <- create_random_distribution(
  type = "lognorm",
  number_of_events = 10,
  meanlog = 2,
  sdlog = 0.5
)

# Constant value
value_dist <- create_random_distribution(
  type = "value",
  number_of_events = 10,
  value = 42
)
}
\references{
Sonnenberg H (2024). kwb.utils: General Utility Functions Developed at KWB. R package version 0.15.0
URL: \url{https://github.com/kwb-r/kwb.utils}
(MIT Licence)
}
