View source: R/create_prob_distribution.R
create_prob_distribution | R Documentation |
Creates an S3 class holding the distribution and parameters from the probability distribution name, its parameters and distribution truncation and discretisation.
The class holding the distribution depends on whether it is a discretised distribution. For continuous and discrete distributions S3 classes from the distributional package are used, for discretised continuous distributions the an S3 class from the distcrete package is used.
For details on the properties of the distribution classes
from each respective package see their documentation (either
?distributional
or ?distcrete
)
create_prob_distribution(
prob_distribution,
prob_distribution_params,
discretise = FALSE,
truncation = NA,
...
)
prob_distribution |
A |
prob_distribution_params |
A named vector of probability distribution parameters. |
discretise |
A boolean |
truncation |
A |
... |
dots Extra arguments to be passed to
distributional or distcrete functions that construct the S3
distribution objects. To see which arguments can be adjusted for discretised
distributions see |
Truncation is enabled only for continuous distributions as there is no truncation implemented in distcrete.
By default the discretisation of continuous distributions uses a
discretisation interval (interval
) of 1. If the unit of the distribution
is days, then this will be discretised by day. The endpoint weighting (w
)
for the discretisation is 1. w
can be [0,1]
. For more information please
see distcrete::distcrete()
.
An S3 class containing the probability distribution or a character
string if the parameters of the probability distribution are unknown.
# example with continuous distribution without truncation
create_prob_distribution(
prob_distribution = "gamma",
prob_distribution_params = c(shape = 1, scale = 1),
discretise = FALSE,
truncation = NA
)
# example with continuous distribution with truncation
create_prob_distribution(
prob_distribution = "gamma",
prob_distribution_params = c(shape = 1, scale = 1),
discretise = FALSE,
truncation = 10
)
# example with discrete distribution
create_prob_distribution(
prob_distribution = "gamma",
prob_distribution_params = c(shape = 1, scale = 1),
discretise = TRUE,
truncation = NA
)
# example passing extra arguments to distcrete
create_prob_distribution(
prob_distribution = "gamma",
prob_distribution_params = c(shape = 1, scale = 1),
discretise = TRUE,
truncation = NA,
w = 0.5
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.