Learn R Programming

⚠️There's a newer version (0.4.0) of this package.Take me there.

Distributacalcul

The goal of Distributacalcul is to simplify the life of students and scientists by offering premade functions for various functions of probability distributions. Functions calculate moments of the distribution (mean, variance, kth moment) as well as the expected value of functions of the distribution (truncated mean, stop-loss, mean excess loss, etc.). In addition, the package includes some risk measures (Value-at-Risk and Tail Value-at-Risk).

This package depends primarily the stats package.

Installation

You can install the released version of Distributacalcul from CRAN with:

install.packages("Distributacalcul")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("alec42/Distributacalcul_Package")

Example

This is a basic example which shows you the typical use of the functions:

library(Distributacalcul)
##  Various moments:
E_beta(shape1 = 2, shape2 = 4) # E[X]
#> [1] 0.3333333
V_beta(shape1 = 2, shape2 = 4) # V(X)
#> [1] 0.03174603
kthmoment_beta(k = 3, shape1 = 2, shape2 = 4) # E[X^k]
#> [1] 0.07142857

##  Expected value of functions:
Elim_beta(d = 0.3, shape1 = 2, shape2 = 4) # E[min(X; d)]
#> [1] 2.19811
Etronq_beta(d = .3, shape1 = 2, shape2 = 4, less.than.d = TRUE) # E[X * 1_{X <= d}]
#> [1] 0.08523
Etronq_beta(d = .3, shape1 = 2, shape2 = 4, less.than.d = FALSE) # E[X * 1_{X > d}]
#> [1] 0.2481033
Mexcess_beta(d = .3, shape1 = 2, shape2 = 4) # E[(X - d | X > d)]
#> [1] 0.169697
SL_beta(d = .3, shape1 = 2, shape2 = 4) # E[max(X - d, 0)]
#> [1] 0.4065693

##  Risk measures:
TVaR_beta(kap = 0.99, shape1 = 2, shape2 = 4) # TVaR_{k}(X)
#> [1] 0.8239414
VaR_beta(kap = 0.99, shape1 = 2, shape2 = 4) # VaR_{k}(X) = F_X^(-1)(k)
#> [1] 0.7779277

Syntax:

FunctionSyntax
MeanE_distribution
K-th momentkthmoment_distribution
Truncated meanEtronq_distribution
Limited expected valueElim_distribution
VarianceV_distribution
Stop-lossSL_distribution
Excess of meanMexcess_distribution
Moment Generating FunctionMGF_distribution
Probability Generating FunctionPGF_distribution
Densityddistribution
Cumulative density functionpdistribution
Value-at-Risk (percentile)TVaR_distribution
Tail Value-at-RiskVaR_distribution

Included distributions and functions

Continuous distributions

ErlangInverse GaussianWeibullBurr
MeanXXXX
kth momentXXX
VarianceXXXX
Truncated meanXXXX
Limited meanXXXX
Stop-lossXXXX
Excess of meanXXXX
Moment Generating FunctionXX
Probability Density FunctionX
Cumulative Probability Density FunctionX
Value-at-RiskXXXX
Tail Value-at-RiskXXXX

Table continues below

Log-logisticBetaGammaPareto
MeanXXXX
kth momentXXXX
VarianceXXXX
Truncated meanXXXX
Limited meanXXXX
Stop-lossXXXX
Excess of meanXXXX
Moment Generating FunctionXX
Probability Density Function
Cumulative Probability Density Function
Value-at-RiskXXXX
Tail Value-at-RiskXXXX

Table continues below

LognormalExponentialUniformNormal
MeanXXXX
kth momentXXX
VarianceXXXX
Truncated meanXXXX
Limited meanXXXX
Stop-lossXXXX
Excess of meanXXXX
Moment Generating FunctionXX
Probability Density Function
Cumulative Probability Density Function
Value-at-RiskXXXX
Tail Value-at-RiskXXXX

Discrete distributions

BinomialNegative BinomialPoisson
MeanXXX
kth moment
VarianceXXX
Truncated meanXXX
Limited mean
Stop-loss
Excess of mean
Moment Generating FunctionXXX
Probability Generating FunctionXXX
Probability Density Function
Cumulative Probability Density Function
Value-at-RiskX
Tail Value-at-RiskXXX

Table continues below

UniformLogarithmicHypergeometric
MeanXXX
kth moment
VarianceXXX
Truncated mean
Limited mean
Stop-loss
Excess of mean
Moment Generating FunctionX
Probability Generating FunctionX
Probability Density FunctionX
Cumulative Probability Density FunctionX
Value-at-Risk
Tail Value-at-Risk

Updates

DateModifications
26/07/2019Initial creation of package
12/09/2019Completion of creation of all necessary function files
17/11/2019Merger of tvarPackage, beginning of documentation creation.
20/05/2020Addition of Shiny component.
02/06/2020Completion of documentation, first attempt of a submission to CRAN.
02/07/2020Modifications according to CRAN’s notes, version 0.2.0.

Copy Link

Version

Install

install.packages('Distributacalcul')

Monthly Downloads

249

Version

0.2.2

License

MIT + file LICENSE

Maintainer

Alec James van Rassel

Last Published

June 13th, 2020

Functions in Distributacalcul (0.2.2)

E_beta

Expected value of the Beta distribution
E_exp

Expected value of the Exponential distribution
E_hyper

Expected value of the Hypergeometric distribution
E_gamma

Expected value of the Gamma distribution
E_IG

Expected value of the Inverse Gaussian distribution
E_llogis

Expected value of the Loglogistic distribution
E_pareto

Expected value of the Pareto distribution
E_pois

Expected value of the Poisson distribution
E_binom

Expected value of the Binomial distribution
E_unif

Expected value of the Uniform distribution
E_unifD

Expected value of the (discrete) Uniform distribution
Elim_exp

Limited mean of the Exponential distribution
Elim_erlang

Limited mean of the Erlang distribution
Elim_weibull

Limited mean of the Weibull distribution
E_lnorm

Expected value of the Lognormal distribution
E_erlang

Expected value of the Erlang distribution
E_burr

Expected value of the Burr distribution
Etronq_IG

Truncated mean of the Inverse Gaussian distribution
E_weibull

Expected value of the Weibull distribution
Etronq_norm

Truncated mean of the Normal distribution
E_logarithmic

Expected value of the Logarithmic distribution
Elim_beta

Limited mean of the Beta distribution
Elim_burr

Limited mean of the Burr distribution
Elim_lnorm

Limited mean of the Lognormal distribution
Etronq_pareto

Truncated mean of the Pareto distribution
Elim_gamma

Limited mean of the Gamma distribution
Elim_norm

Limited mean of the Normal distribution
Elim_llogis

Limited mean of the Loglogistic distribution
E_negbinom

Expected value of the negative binomial distribution
E_norm

Expected value of the Normal distribution
Elim_IG

Limited mean of the Inverse Gaussian distribution
Etronq_lnorm

Truncated mean of the Lognormal distribution
Etronq_llogis

Truncated mean of the Loglogistic distribution
Etronq_pois

Truncated mean of the Poisson distribution
Etronq_beta

Truncated mean of the Beta distribution
Etronq_binom

Truncated mean of the Binomial distribution
Mexcess_lnorm

Mean excess loss of the Lognormal distribution
Etronq_weibull

Truncated mean of the Weibull distribution
Etronq_burr

Truncated mean of the Burr distribution
Etronq_erlang

Truncated mean of the Erlang distribution
Etronq_unif

Truncated mean of the Uniform distribution
MGF_logarithmic

Moment Generating Function of the Logarithmic distribution
MGF_gamma

Moment Generating Function of the Gamma distribution
PGF_negbinom

Probability Generating Function of the Negative Binomial distribution
PGF_logarithmic

Probability Generating Function of the Logarithmic distribution
MGF_IG

Moment Generating Function of the Inverse Gaussian distribution
MGF_beta

Moment Generating Function of the Beta distribution
Mexcess_norm

Mean excess loss of the Normal distribution
MGF_binom

Moment Generating Function of the Binomial distribution
MGF_negbinom

Moment Generating Function of the Negative Binomial distribution
MGF_norm

Moment Generating Function of the Normal distribution
Mexcess_IG

Mean excess loss of the Inverse Gaussian distribution
MGF_pois

Moment Generating Function of the Poisson distribution
TVaR_pois

Tail Value-at-Risk of the Poisson distribution
TVaR_exp

Tail Value-at-Risk of the Exponential distribution
SL_gamma

Stop-loss of the Gamma distribution
TVaR_gamma

Tail Value-at-Risk of the Gamma distribution
SL_llogis

Stop-loss of the Loglogistic distribution
SL_weibull

Stop-loss of the Weibull distribution
Elim_pareto

Limited mean of the Pareto distribution
Mexcess_gamma

Mean excess loss of the Gamma distribution
V_burr

Variance of the Burr distribution
V_unif

Variance of the Uniform distribution
TVaR_weibull

Tail Value-at-Risk of the Weibull Distribution
V_erlang

Variance of the Erlang distribution
TVaR_IG

Tail Value-at-Risk of the Inverse Gaussian distribution
V_IG

Variance of the Inverse Gaussian distribution
V_unifD

Variance of the (discrete) Uniform distribution
VaR_exp

Value-at-Risk of the Exponential distribution
SL_beta

Stop-loss of the Beta distribution
SL_burr

Stop-loss of the Burr distribution
VaR_gamma

Value-at-Risk of the Gamma distribution
Mexcess_llogis

Mean excess loss of the Loglogistic distribution
p_BINCOMP

Compound Binomial Distribution
lawParametersBoxUI

Interactive distribution visualization (UI side)
V_beta

Variance of the Beta distribution
TVaR_beta

Tail Value-at-Risk of the Beta distribution
V_weibull

Variance of the Weibull distribution
V_binom

Variance of the Binomial distribution
TVaR_binom

Tail Value-at-Risk of the Binomial distribution
VaR_IG

Value-at-Risk of the Inverse Gaussian distribution
Mexcess_exp

Mean excess loss of the Exponential distribution
Mexcess_erlang

Mean excess loss of the Erlang distribution
SL_lnorm

Stop-loss of the Lognormal distribution
Elim_unif

Limited mean of the Uniform distribution
VaR_llogis

Value-at-Risk of the Loglogistic distribution
PGF_binom

Probability Generating Function of the Binomial distribution
SL_IG

Stop-loss of the Inverse Gaussian distribution
Mexcess_weibull

Mean excess loss of the Weibull distribution
PGF_pois

Probability Generating Function of the Poisson distribution
TVaR_llogis

Tail Value-at-Risk of the Loglogistic distribution
kthmoment_weibull

kth moment of the Weibull distribution
derlang

Density function of the Erlang distribution
kthmoment_beta

kth moment of the Beta distribution
VaR_lnorm

Value-at-Risk of the Lognormal distribution
SL_norm

Stop-loss of the Normal distribution
TVaR_lnorm

Tail Value-at-Risk of the Lognormal distribution
V_gamma

Variance of the Gamma distribution
V_exp

Variance of the Exponential distribution
VaR_beta

Value-at-Risk of the Beta distribution
VaR_binom

Value-at-Risk of the Binomial distribution
VaR_pareto

Value-at-Risk of the Pareto distribution
kthmoment_burr

kth moment of the Burr distribution
VaR_norm

Value-at-Risk of the Normal distribution
TVaR_unif

Tail Value-at-Risk of the Uniform distribution
kthmoment_erlang

kth moment of the Erlang distribution
V_hyper

Variance of the Hypergeometric distribution
SL_unif

Stop-loss of the Uniform distribution
SL_pareto

Stop-loss of the Pareto distribution
p_pareto

Cumulative density function of the Pareto distribution
p_unifD

Cumulative probability mass function of the (discrete) Uniform distribution
d_pareto

Density function of the Pareto distribution
V_pareto

Variance of the Pareto distribution
V_llogis

Variance of the Loglogistic distribution
V_pois

Variance of the Poisson distribution
d_unifD

Probability mass function of the (discrete) Uniform Distribution
TVaR_pareto

Tail Value-at-Risk of the Pareto distribution
TVaR_norm

Tail Value-at-Risk of the Normal distribution
lawParametersBox

Interactive distribution visualization (server side)
kthmoment_exp

kth moment of the Exponential distribution
V_lnorm

Variance of the Lognormal distribution
V_logarithmic

Variance of the Logarithmic distribution
VaR_burr

Value-at-Risk of the Burr distribution
Etronq_exp

Truncated mean of the Exponential distribution
Etronq_gamma

Truncated mean of the Gamma distribution
MGF_exp

Moment Generating Function of the Exponential distribution
MGF_erlang

Moment Generating Function of the Erlang distribution
VaR_unif

Value-at-Risk of the Uniform distribution
VaR_erlang

Value-at-Risk of the Erlang distribution
Mexcess_burr

Mean excess loss of the Burr distribution
Mexcess_beta

Mean excess loss of the Beta distribution
Mexcess_pareto

Mean excess loss of the Pareto distribution
SL_erlang

Stop-loss of the Erlang distribution
Mexcess_unif

Mean excess loss of the Uniform distribution
SL_exp

Stop-loss of the Exponential distribution
kthmoment_llogis

kth moment of the Loglogistic distribution
VaR_weibull

Value-at-Risk of the Weibull distribution
kthmoment_lnorm

kth moment of the Lognormal distribution
kthmoment_gamma

kth moment of the Gamma distribution
V_norm

Variance of the Normal distribution
kthmoment_unif

kth moment of the Uniform distribution
TVaR_erlang

Tail Value-at-Risk of the Erlang distribution
V_negbinom

Variance of the negative binomial distribution
TVaR_burr

Tail Value-at-Risk of the Burr distribution
kthmoment_pareto

kth moment of the Pareto distribution
perlang

Cumulative density function of the Erlang distribution
p_BNCOMP

Compound Negative Binomial Distribution
p_PCOMP

Compound Poisson Distribution
Distributacalcul_vis

Interactive distribution visualization