## Main Features

distr6 is not intended to replace the base R distributions function but instead to give an alternative that focuses on distributions as objects that can be manipulated and accessed as required. The main features therefore centre on OOP practices, design patterns and API design. Of particular note:

All distributions in base R introduced as objects with methods for common statistical functions including pdf, cdf, inverse cdf, simulation, mean, variance, skewness and kurtosis

B <- Binomial$new(prob = 0.5, size = 10) B$pdf(1:10) #> [1] 0.0097656250 0.0439453125 0.1171875000 0.2050781250 0.2460937500 #> [6] 0.2050781250 0.1171875000 0.0439453125 0.0097656250 0.0009765625 B$kurtosis() #> [1] -0.2 B$rand(5) #> [1] 7 7 4 7 6 summary(B) #> Binomial Probability Distribution. Parameterised with: #> c("prob", "size") = c(0.5, 10) #> #> Quick Statistics #> Mean: 5 #> Variance: 2.5 #> Skewness: 0 #> Ex. Kurtosis: -0.2 #> #> Support: {0, 1,...,9, 10} Scientific Type: â0 #> #> Traits: discrete; univariate #> Properties: symmetric; platykurtic; no skew

Flexible construction of distributions for common parameterisations

Exponential$new(rate = 2) #> Exp(rate = 2) Exponential$new(scale = 2) #> Exp(scale = 2) Normal$new(mean = 0, prec = 2) #> Norm(mean = 0, prec = 2) Normal$new(mean = 0, sd = 3)$parameters() #> id value support description #> 1: mean 0.0000000 â Mean - Location Parameter #> 2: var 9.0000000 â+ Variance - Squared Scale Parameter #> 3: sd 3.0000000 â+ Standard Deviation - Scale Parameter #> 4: prec 0.1111111 â+ Precision - Inverse Squared Scale Parameter

Decorators for extending functionality of distributions to more complex modelling methods

B <- Binomial$new() decorate(B, ExoticStatistics) #> B is now decorated with ExoticStatistics #> Binom(prob = 0.5, size = 10) B$survival(2) #> [1] 0.9453125 decorate(B, CoreStatistics) #> B is now decorated with CoreStatistics #> Binom(prob = 0.5, size = 10) B$kthmoment(6) #> Results from numeric calculations are approximate only. Better results may be available. #> [1] 190

S3 compatibility to make the interface more flexible for users who are less familiar with OOP

B <- Binomial$new() mean(B) # B$mean() #> [1] 5 variance(B) # B$variance() #> [1] 2.5 cdf(B, 2:5) # B$cdf(2:5) #> [1] 0.0546875 0.1718750 0.3769531 0.6230469

Wrappers including truncation, huberization and product distributions for manipulation and composition of distributions.

B <- Binomial$new() TruncatedDistribution$new(B, lower = 2, upper = 5) #Or: truncate(B,2,5) #> TruncBinom(Binom_prob = 0.5, Binom_size = 10) N <- Normal$new() MixtureDistribution$new(list(B,N), weights = c(0.1, 0.9)) #> BinomMixNorm(Binom_prob = 0.5, Binom_size = 10, Norm_mean = 0, Norm_var = 1) ProductDistribution$new(list(B,N)) #> BinomProdNorm(Binom_prob = 0.5, Binom_size = 10, Norm_mean = 0, Norm_var = 1)

Additionally set6 is used for symbolic representation of sets for Distribution typing

Binomial$new()$type #> â0 Binomial$new()$support #> {0, 1,...,9, 10}