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).

In addition, this package has recently added probability functions for various bivariate copulas. Functions calculate the density associated with the copula, the distribution function and also simulations.

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:
expValBeta(shape1 = 2, shape2 = 4) # E[X]
#> [1] 0.3333333
varBeta(shape1 = 2, shape2 = 4) # V(X)
#> [1] 0.03174603
kthMomentBeta(k = 3, shape1 = 2, shape2 = 4) # E[X^k]
#> [1] 0.07142857

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

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

Syntax:

FunctionSyntax
MeanexpValDistribution
K-th momentkthMomentDistribution
Truncated meanexpValTruncDistribution
Limited expected valueexpValLimDistribution
VariancevarDistribution
Stop-lossstopLossDistribution
Excess of meanmeanExcessDistribution
Moment Generating FunctionmgfDistribution
Probability Generating FunctionpgfDistribution
DensitydDistribution
Cumulative density functionpDistribution
Value-at-Risk (percentile)VatRDistribution
Tail Value-at-RiskTVatRDistribution
Copula DensitycdCopula
Copula Distribution FunctioncCopula
Copula Simulation FunctioncrCopula

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 FunctionXX
Cumulative Probability Density FunctionXX
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 FunctionXXX
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-RiskX
Tail Value-at-Risk

Copulas

  1. Independence Copula
  2. Fréchet Lower Bound Copula
  3. Fréchet Upper Bound Copula
  4. Fréchet Copula
  5. Bivariate Gumbel Copula
  6. Bivariate Clayton Copula
  7. Bivariate Ali-Mikhail-Haq Copula
  8. Bivariate Cuadras-Augé Copula
  9. Bivariate Marshall-Olkin Copula
  10. Bivariate Frank Copula
  11. Bivariate Eyraud-Farlie-Gumbel-Morgenstern (EFGM) Copula

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.
02/13/2020Small fixes, version 0.2.2.
31/08/2020Significant changes and additions, version 0.3.0.
31/12/2023Removal of shiny components and vignettes, version 0.4.0.

Copy Link

Version

Down Chevron

Install

install.packages('Distributacalcul')

Monthly Downloads

203

Version

0.4.0

License

MIT + file LICENSE

Last Published

January 10th, 2024

Functions in Distributacalcul (0.4.0)