MyNixOS website logo
Description

Probability Distribution Functions.

Calculates expected values, variance, different moments (kth moment, truncated mean), stop-loss, mean excess loss, Value-at-Risk (VaR) and Tail Value-at-Risk (TVaR) as well as some density and cumulative (survival) functions of continuous, discrete and compound distributions. This package also includes a visual 'Shiny' component to enable students to visualize distributions and understand the impact of their parameters. This package is intended to expand the 'stats' package so as to enable students to develop an intuition for probability.

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

Version

0.4.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows