m2bgumbel {bgumbel} | R Documentation |
Bimodal Gumbel: Theoretical E(X^2)
Description
Bimodal Gumbel: Theoretical E(X^2)
Usage
m2bgumbel(mu, sigma, delta)
Arguments
mu |
First location parameter. |
sigma |
Scale parameter. |
delta |
Second location parameter. |
Value
Vector.
Examples
(EX2 <- m2bgumbel(mu = -2, sigma = 1, delta = -1))
# Comparison: Theoretical E(X^2) and empirical second moment
x <- rbgumbel(100000, mu = -2, sigma = 1, delta = -1)
mean(x^2)
abs(EX2 - mean(x))/abs(EX2) # relative error
# Variance
EX <- m1bgumbel(mu = -2, sigma = 1, delta = -1)
EX2 - EX^2
var(x)
abs(EX2 - EX^2 - var(x))/abs(EX2 - EX^2) # relative error
# grid 1
mu <- seq(-5, 5, length.out = 100)
delta <- seq(-5, 5, length.out = 100)
z <- outer(
X <- mu,
Y <- delta,
FUN = function(x, y) m2bgumbel(mu = x, sigma = 1, delta = y)
)
persp(x = mu, y = delta, z = z, theta = -30, ticktype = 'detailed')
# grid 2
mu <- seq(-5, 5, length.out = 100)
delta <- seq(-5, 5, length.out = 100)
sigmas <- seq(.1, 10, length.out = 20)
for (sigma in sigmas) {
z <- outer(
X <- mu,
Y <- delta,
FUN = function(x, y) m2bgumbel(mu = x, sigma = sigma, delta = y)
)
persp(x = mu, y = delta, z = z, theta = -45, zlab = 'E(X^2)')
Sys.sleep(.5)
}
[Package bgumbel version 0.0.3 Index]