Learn R Programming

distributional (version 0.9.0)

parameters: Extract the parameters of a distribution

Description

[Experimental]

Some distributions (such as dist_inflated() and dist_transformed()) are defined in terms of another distribution, which returns a distribution as one of their parameters. By default, this underlying distribution is returned as-is in a column of the parameters() result. Setting recursive = TRUE will recursively compute the parameters of these inner distributions, returning a flat data frame of all parameters.

Usage

parameters(x, ...)

# S3 method for distribution parameters(x, recursive = FALSE, ...)

Value

A data frame of parameters, with one row per distribution and one column per parameter. The result never contains data frame (or distribution) columns.

Arguments

x

The distribution(s).

...

Additional arguments used by methods.

recursive

If TRUE, parameters which are themselves distributions (such as the base distribution of a dist_inflated() or dist_transformed()) are recursively expanded into their own parameters instead of being returned as a distribution.

Examples

Run this code
dist <- c(
  dist_normal(1:2),
  dist_poisson(3),
  dist_multinomial(size = c(4, 3),
  prob = list(c(0.3, 0.5, 0.2), c(0.1, 0.5, 0.4)))
  )
parameters(dist)

# Distribution-valued parameters (such as the inflated distribution
# below) are returned as-is by default.
infl_dist <- dist_inflated(dist_negative_binomial(10, 0.6), prob = 0.5)
parameters(infl_dist)

# With recursive = TRUE, the inflated distribution's parameters are
# expanded into a flat data frame.
parameters(infl_dist, recursive = TRUE)

Run the code above in your browser using DataLab