InverseGamma | R Documentation |
A R6 class to represent an inverse Gamma distribution.
See Wikipedia.
alpha
Get or set the value of alpha
.
beta
Get or set the value of beta
.
new()
New inverse Gamma distribution.
InverseGamma$new(alpha, beta)
alpha
shape parameter, >0
beta
scale parameter, >0
An inverseGamma
object.
d()
Density function of the inverse Gamma distribution.
InverseGamma$d(x, log = FALSE)
x
vector of positive numbers
log
Boolean, whether to return the logarithm of the density
The density or the log-density evaluated at x
.
p()
Cumulative distribution function of the inverse Gamma distribution.
InverseGamma$p(q, lower = TRUE)
q
numeric vector of quantiles
lower
Boolean, whether to deal with the lower tail
The cumulative probabilities corresponding to q
.
q()
Quantile function of the inverse Gamma distribution.
InverseGamma$q(p, lower = TRUE)
p
numeric vector of probabilities
lower
Boolean, whether to deal with the lower tail
The quantiles corresponding to p
.
r()
Sampling from the inverse Gamma distribution.
InverseGamma$r(n)
n
number of simulations
A numeric vector of length n
.
mean()
Mean of the inverse Gamma distribution.
InverseGamma$mean()
The mean of the inverse Gamma distribution.
median()
Median of the inverse Gamma distribution.
InverseGamma$median()
The median of the inverse Gamma distribution.
mode()
Mode of the inverse Gamma distribution.
InverseGamma$mode()
The mode of the inverse Gamma distribution.
sd()
Standard deviation of the inverse Gamma distribution.
InverseGamma$sd()
The standard deviation of the inverse Gamma distribution.
variance()
Variance of the inverse Gamma distribution.
InverseGamma$variance()
The variance of the inverse Gamma distribution.
skewness()
Skewness of the inverse Gamma distribution.
InverseGamma$skewness()
The skewness of the inverse Gamma distribution.
kurtosis()
Kurtosis of the inverse Gamma distribution.
InverseGamma$kurtosis()
The kurtosis of the inverse Gamma distribution.
kurtosisExcess()
Kurtosis excess of the inverse Gamma distribution.
InverseGamma$kurtosisExcess()
The kurtosis excess of the inverse Gamma distribution.
clone()
The objects of this class are cloneable with this method.
InverseGamma$clone(deep = FALSE)
deep
Whether to make a deep clone.
if(require("plotly")) {
x_ <- seq(0, 2, length.out = 100L)
alpha_ <- seq(0.5, 2.5, length.out = 100L)
dsty <- vapply(alpha_, function(alpha) {
InverseGamma$new(alpha, beta = 1)$d(x_)
}, numeric(length(x_)))
#
txt <- matrix(NA_character_, nrow = length(x_), ncol = length(alpha_))
for(i in 1L:nrow(txt)) {
for(j in 1L:ncol(txt)) {
txt[i, j] <- paste0(
"x: ", formatC(x_[i]),
"<br> alpha: ", formatC(alpha_[j]),
"<br> density: ", formatC(dsty[i, j])
)
}
}
#
plot_ly(
x = ~alpha_, y = ~x_, z = ~dsty, type = "surface",
text = txt, hoverinfo = "text", showscale = FALSE
) %>% layout(
title = "Inverse Gamma distribution",
margin = list(t = 40, r= 5, b = 5, l = 5),
scene = list(
xaxis = list(
title = "alpha"
),
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.