In the previous tutorial we looked at multivariate distributions and how to use the d/p/q/r functions to evaluate multiple points of these. This tutorial concludes the ‘Basic’ set of tutorials with the use of ‘listing’ in distr6.

## Listing

Currently distr6 includes 5 listing functions: listDistributions(), listDecorators(), listWrappers(), listKernels(), listSpecialSets(). These are essentially ways of listing the R6 classes implemented in the R6 API. We will only discuss the listDistributions() function here as the others cover classes that we haven’t discussed yet, but hopefully are intuitive to you and have a similar interface to listDistributions().

## listDistributions

listDistributions() is used to list every implemented probability distribution in distr6. The default parameters return a data.table of every implemented distribution including their traits and the package that their d/p/q/r methods are implemented in. For example a distribution with package stats means that the d/p/q/r methods interface the R stats functions whereas a distribution with package distr6 means the methods are written in distr6. We’ve added the head() method just to save space.

head(listDistributions())
#>    ShortName      ClassName   Type ValueSupport VariateForm Package   Tags
#>       <char>         <char> <char>       <char>      <char>  <char> <char>
#> 1:       Arc        Arcsine      ℝ   continuous  univariate       - limits
#> 2:   Arrdist        Arrdist    ℝ^K     discrete  univariate       -
#> 3:      Bern      Bernoulli     ℕ0     discrete  univariate   stats
#> 4:      Beta           Beta     ℝ+   continuous  univariate   stats
#> 5:    BetaNC BetaNoncentral     ℝ+   continuous  univariate   stats
#> 6:     Binom       Binomial     ℕ0     discrete  univariate   stats limits
#>      Alias
#>     <char>
#> 1:      AS
#> 3:       B
#> 4:      BT
#> 5:    BTNC
#> 6: BM, Bin

To see a simplified version of the list, add the simplify = TRUE argument

head(listDistributions(simplify = TRUE))
#> [1] "Arcsine"        "Arrdist"        "Bernoulli"      "Beta"
#> [5] "BetaNoncentral" "Binomial"

Finally this list can be filtered to help you find a distribution with specific traits, for example for a multivariate distribution

head(listDistributions(filter = list(variateform = "multivariate")))
#>    ShortName          ClassName    Type ValueSupport  VariateForm    Package
#>       <char>             <char>  <char>       <char>       <char>     <char>
#> 1:      Diri          Dirichlet [0,1]^K   continuous multivariate extraDistr
#> 2:     EmpMV        EmpiricalMV       ℝ     discrete multivariate          -
#> 3:  Multinom        Multinomial    ℕ0^K     discrete multivariate extraDistr
#> 4: MultiNorm MultivariateNormal     ℝ^K   continuous multivariate          -
#>        Tags  Alias
#>      <char> <char>
#> 1:             DRC
#> 2:             EMV
#> 3:   limits     MN
#> 4: locscale    MVN

# The trait name is case-insensitive
#>    ShortName          ClassName    Type ValueSupport  VariateForm    Package
#>       <char>             <char>  <char>       <char>       <char>     <char>
#> 1:      Diri          Dirichlet [0,1]^K   continuous multivariate extraDistr
#> 2:     EmpMV        EmpiricalMV       ℝ     discrete multivariate          -
#> 3:  Multinom        Multinomial    ℕ0^K     discrete multivariate extraDistr
#> 4: MultiNorm MultivariateNormal     ℝ^K   continuous multivariate          -
#>        Tags  Alias
#>      <char> <char>
#> 1:             DRC
#> 2:             EMV
#> 3:   limits     MN
#> 4: locscale    MVN

Or for multiple filters:

head(listDistributions(filter = list(variateform = "multivariate", package = "extraDistr")))
#>    ShortName   ClassName    Type ValueSupport  VariateForm    Package   Tags
#>       <char>      <char>  <char>       <char>       <char>     <char> <char>
#> 1:      Diri   Dirichlet [0,1]^K   continuous multivariate extraDistr
#> 2:  Multinom Multinomial    ℕ0^K     discrete multivariate extraDistr limits
#>     Alias
#>    <char>
#> 1:    DRC
#> 2:     MN

## Summary

In this tutorial we looked at the listDistributions() function so that you don’t have to remember which are implemented in distr6. In this set of tutorials we covered the basics of constructing a (univariate) distribution, getting and setting parameters, evaluating statistical results and extending all this to multivariate distributions. The next set of tutorials cover more advanced functionality including decorators for numeric results, wrappers for composite distributions, custom distributions, S3 functionality, and symbolic sets.