GeneralizedInverseGaussian | R Documentation |
A R6 class to represent a generalized inverse Gaussian distribution.
See Wikipedia.
theta
Get or set the value of theta
.
eta
Get or set the value of eta
.
lambda
Get or set the value of lambda
.
new()
New generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$new(theta, eta, lambda)
theta
concentration parameter, >0
eta
scale parameter, >0
lambda
parameter (denoted by p
on Wikipedia)
A GeneralizedInverseGaussian
object.
d()
Density function of the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$d(x, log = FALSE)
x
vector of positive numbers
log
Boolean, whether to return the log-density
The density or the log-density evaluated at x
.
p()
Cumulative distribution function of the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$p(q)
q
numeric vector of quantiles (>= 0
)
The cumulative probabilities corresponding to q
, with two
attributes (see the Note).
q()
Quantile function of the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$q(p, bounds = NULL)
p
numeric vector of probabilities
bounds
bounds enclosing the quantiles to be found (see the
Note), or NULL
for automatic bounds
The quantiles corresponding to p
.
r()
Sampling from the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$r(n)
n
number of simulations
A numeric vector of length n
.
mean()
Mean of the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$mean()
The mean of the generalized inverse Gaussian distribution.
mode()
Mode of the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$mode()
The mode of the generalized inverse Gaussian distribution.
sd()
Standard deviation of the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$sd()
The standard deviation of the generalized inverse Gaussian distribution.
variance()
Variance of the generalized inverse Gaussian distribution.
GeneralizedInverseGaussian$variance()
The variance of the generalized inverse Gaussian distribution.
clone()
The objects of this class are cloneable with this method.
GeneralizedInverseGaussian$clone(deep = FALSE)
deep
Whether to make a deep clone.
The cumulative distribution function is evaluated by integrating the
density function (in C++). Its returned value has two attributes: a
numeric vector "error_estimate"
and an integer vector
"error_code"
. The error code is 0 if no problem is detected. If an
error code is not 0, a warning is thrown. The quantile function is
evaluated by root-finding and then the user must provide some bounds
enclosing the values of the quantiles or choose the automatic bounds.
A maximum number of iterations is fixed in the root-finding algorithm.
If it is reached, a warning is thrown.
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]),
"<br> lambda: ", formatC(lambda_[j]),
"<br> 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"
)
)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.