Helper functions for constructing an SDistribution (with dstr) or VectorDistribution (with dstrs).

dstr(d, ..., pars = list(...), decorators = NULL)

dstrs(d, pars = NULL, ...)

Arguments

d

(character(1))
Distribution. Can be the ShortName or ClassName from listDistributions().

...

(ANY)
Passed to the distribution constructor, should be parameters or decorators.

pars

(list())
List of parameters of same length as d corresponding to distribution parameters.

decorators

(character())
Passed to distribution constructor.

Examples

# Construct standard Normal and  distribution
dstr("Norm") # ShortName
#> Norm(mean = 0, var = 1) 
dstr("Normal") # ClassName
#> Norm(mean = 0, var = 1) 

# Construct Binomial(5, 0.1)
dstr("Binomial", size = 5, prob = 0.1)
#> Binom(prob = 0.1, size = 5) 

# Construct decorated Gamma(2, 1)
dstr("Gamma", shape = 2, rate = 1,
     decorators = "ExoticStatistics")
#> Gamma(rate = 1, shape = 2) 

# Or with a list
dstr("Gamma", pars = list(shape = 2, rate = 4))
#> Gamma(rate = 4, shape = 2) 

# Construct vector with dstrs

# Binomial and Gamma with default parameters
dstrs(c("Binom", "Gamma"))
#> Binom Gamma 

# Binomial with set parameters and Gamma with
#  default parameters
dstrs(c("Binom", "Gamma"), list(list(size = 4), NULL))
#> Binom Gamma 

# Binomial and Gamma with set parameters
dstrs(c("Binom", "Gamma"),
     list(list(size = 4), list(rate = 2, shape = 3)))
#> Binom Gamma 

# Multiple Binomials
dstrs("Binom", data.frame(size = 1:5, prob = 0.5))
#> Binom1 Binom2 ... Binom4 Binom5