Learn R Programming

boodist (version 1.0.0)

GeneralizedInverseGaussian: Generalized inverse Gaussian distribution

Description

A R6 class to represent a generalized inverse Gaussian distribution.

Arguments

Active bindings

theta

Get or set the value of theta.

eta

Get or set the value of eta.

lambda

Get or set the value of lambda.

Methods


Method new()

New generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$new(theta, eta, lambda)

Arguments

theta

concentration parameter, >0

eta

scale parameter, >0

lambda

parameter (denoted by p on Wikipedia)

Returns

A GeneralizedInverseGaussian object.


Method d()

Density function of the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$d(x, log = FALSE)

Arguments

x

vector of positive numbers

log

Boolean, whether to return the log-density

Returns

The density or the log-density evaluated at x.


Method p()

Cumulative distribution function of the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$p(q)

Arguments

q

numeric vector of quantiles (>= 0)

Returns

The cumulative probabilities corresponding to q, with two attributes (see the Note).


Method q()

Quantile function of the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$q(p, bounds = NULL)

Arguments

p

numeric vector of probabilities

bounds

bounds enclosing the quantiles to be found (see the Note), or NULL for automatic bounds

Returns

The quantiles corresponding to p.


Method r()

Sampling from the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$r(n)

Arguments

n

number of simulations

Returns

A numeric vector of length n.


Method mean()

Mean of the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$mean()

Returns

The mean of the generalized inverse Gaussian distribution.


Method mode()

Mode of the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$mode()

Returns

The mode of the generalized inverse Gaussian distribution.


Method sd()

Standard deviation of the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$sd()

Returns

The standard deviation of the generalized inverse Gaussian distribution.


Method variance()

Variance of the generalized inverse Gaussian distribution.

Usage

GeneralizedInverseGaussian$variance()

Returns

The variance of the generalized inverse Gaussian distribution.


Method clone()

The objects of this class are cloneable with this method.

Usage

GeneralizedInverseGaussian$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

See Wikipedia.

Examples

Run this code
if(require("plotly")) {
library(boodist)

x_ <- seq(0, 3, length.out = 100L)
lambda_ <- seq(-1, 1, length.out = 100L)
dsty <- vapply(lambda_, function(lambda) {
  GeneralizedInverseGaussian$new(theta = 1, eta = 1, lambda)$d(x_)
}, numeric(length(x_)))
#
txt <- matrix(NA_character_, nrow = length(x_), ncol = length(lambda_))
for(i in 1L:nrow(txt)) {
  for(j in 1L:ncol(txt)) {
    txt[i, j] <- paste0(
      "x: ", formatC(x_[i]),
      " lambda: ", formatC(lambda_[j]),
      " density: ", formatC(dsty[i, j])
    )
  }
}
#
plot_ly(
  x = ~lambda_, y = ~x_, z = ~dsty, type = "surface",
  text = txt, hoverinfo = "text", showscale = FALSE
) %>% layout(
  title = "Generalized inverse Gaussian distribution",
  margin = list(t = 40, r= 5, b = 5, l = 5),
  scene = list(
    xaxis = list(
      title = "lambda"
    ),
    yaxis = list(
      title = "x"
    ),
    zaxis = list(
      title = "density"
    )
  )
)
}

Run the code above in your browser using DataLab