Density, distribution function, quantile function and
random generation for the normal inverse-Gaussian distribution
with parameters p
, a
and b
.
dnig(x, delta, mu, nu, sigma, h = NULL, log = FALSE)
rnig(n, delta, mu, nu, sigma, h = NULL, seed = 0)
pnig(q, delta, mu, nu, sigma, h = NULL, lower.tail = TRUE, log.p = FALSE)
qnig(p, delta, mu, nu, sigma, h = NULL, lower.tail = TRUE, log.p = FALSE)
vector of quantiles.
A numeric value for the location parameter.
A numeric value for the shift parameter.
A numeric value for the shape parameter.
A numeric value for the scaling parameter.
A numeric value for the additional parameter, see details.
logical; if TRUE
, probabilities/densities \(p\) are
returned as \(log(p)\).
number of observations.
Seed for the random generation.
logical; if TRUE
, probabilities are \(P[X\leq x]\),
otherwise, \(P[X>x]\).
vector of probabilities.
dnig gives the density, pnig gives the distribution function, qnig gives the quantile function, and rnig generates random deviates.
Invalid arguments will result in return value NaN, with a warning.
The length of the result is determined by n
for rnig.
The normal inverse-Gaussian distribution has density given by $$f(x; \delta, \mu, \sigma, \nu) = \frac{e^{\nu+\mu(x-\delta)/\sigma^2}\sqrt{\nu\mu^2/\sigma^2+\nu^2}}{\pi\sqrt{\nu\sigma^2+(x-\delta)^2}} K_1(\sqrt{(\nu\sigma^2+(x-\delta)^2)(\mu^2/\sigma^4+\nu/\sigma^2)}),$$ where \(K_p\) is modified Bessel function of the second kind of order \(p\), \(x>0\), \(\nu>0\) and \(\mu,\delta, \sigma\in\mathbb{R}\). See Barndorff-Nielsen (1977, 1978 and 1997) for further details.
The additional parameter h is used when $$V\sim IG(\nu,\nu h^{2})$$. By the infinite divisibility, $$\frac{1}{h} V \sim IG(\nu h, \nu h)$$. Then $$\delta+\mu V + \sigma \sqrt{V} Z$$ has the distribution of $$NIG(\delta=-\mu h,\mu= \mu h, \sigma=\sigma \sqrt{h}, \nu=\nu h).$$
Barndorff-Nielsen, O. (1977) Exponentially decreasing distributions for the logarithm of particle size. Proceedings of the Royal Society of London.
Series A, Mathematical and Physical Sciences. The Royal Society. 353, 401–409. doi:10.1098/rspa.1977.0041
Barndorff-Nielsen, O. (1978) Hyperbolic Distributions and Distributions on Hyperbolae, Scandinavian Journal of Statistics. 5, 151–157.
Barndorff-Nielsen, O. (1997) Normal Inverse Gaussian Distributions and Stochastic Volatility Modelling, Scandinavian Journal of Statistics. 24, 1-13. doi:10.1111/1467-9469.00045
rnig(100, delta = 0, mu = 5, sigma = 1, nu = 1)
#> [1] 3.0257388 9.6889504 4.2446071 1.5415076 0.5418272 3.3624035
#> [7] 2.1686977 1.8692176 0.5324862 4.9950968 4.3523163 2.4497210
#> [13] 8.8218888 1.1076512 0.7349282 8.4377340 7.0840781 5.8457542
#> [19] 6.7750762 2.5053439 9.9595682 2.2682836 2.6594018 3.6601290
#> [25] 2.2871191 15.0977790 10.2363804 1.4753676 1.5248366 3.2247089
#> [31] 1.2533276 1.1787210 1.1709862 3.8108727 31.3484319 1.6001445
#> [37] 1.9458168 1.8303049 4.9137161 4.0136982 2.1266329 1.6181499
#> [43] 7.2565799 0.9987189 23.3948133 6.8163547 8.3738950 0.8993011
#> [49] 11.2184232 3.4701058 3.6689496 1.0410306 0.5216293 3.0778732
#> [55] 3.3430176 2.0550005 2.4080931 0.4824943 20.5455588 1.2074354
#> [61] 3.6191673 1.5394177 2.6175314 3.2515383 2.2284787 1.2675475
#> [67] 2.7985638 2.9004001 5.7505188 23.1383191 16.2791897 3.3603476
#> [73] 1.2030807 5.7001287 7.0470980 7.1296088 18.7068938 3.3332187
#> [79] 16.3856286 2.5263576 2.5316567 10.9670107 1.9993488 2.2326211
#> [85] 1.9932663 1.5191085 4.9167851 2.4390378 3.1841539 10.0383123
#> [91] 17.9415353 2.7665991 1.1719744 1.6399851 1.3280851 0.2870690
#> [97] 3.0007290 6.0358242 2.7867182 1.7345527
#> attr(,"V")
#> [1] 0.4954177 1.5610617 1.2581837 0.2323198 0.1940967 0.5411159 0.3441968
#> [8] 0.3022169 0.1476828 1.0159624 1.3354529 0.5672818 1.7376134 0.2268851
#> [15] 0.4861360 1.8580963 1.6412576 1.1090148 1.2772934 0.6520916 1.9112517
#> [22] 0.4472636 0.4709710 0.6263351 0.5016878 2.2606393 2.1709577 0.1812238
#> [29] 0.3306388 0.5564529 0.2572867 0.3143738 0.2913199 0.7331019 6.2128007
#> [36] 0.4236744 0.4197498 0.2479617 0.9461777 0.6369293 0.4881806 0.4149235
#> [43] 1.4440033 0.2442069 4.3977346 1.0080123 1.5184074 0.1512043 1.8665664
#> [50] 0.8543116 0.4185540 0.2042433 0.1270112 0.3141714 0.5815975 0.4870313
#> [57] 0.5151721 0.2401764 3.9532220 0.1673638 0.5462163 0.2018464 0.7023848
#> [64] 0.6001345 0.4721398 0.1894622 0.3988638 0.6202687 1.1522612 5.1921304
#> [71] 3.6628731 0.8662250 0.3956130 1.0921209 1.2693063 1.3987522 3.2039345
#> [78] 0.7672106 3.7309594 0.4976539 0.3604128 2.3281715 0.3160004 0.4189598
#> [85] 0.6049424 0.1672997 1.0087118 0.8767438 0.4200162 2.0048143 3.0885267
#> [92] 0.5148608 0.1984127 0.4400561 0.2259924 0.1825419 0.6793735 1.0255224
#> [99] 0.6403858 0.4707993
pnig(0.4, delta = 0, mu = 5, sigma = 1, nu = 1)
#> [1] 0.01597497
qnig(0.8, delta = 0, mu = 5, sigma = 1, nu = 1)
#> [1] 7.390234
plot(function(x){dnig(x, delta = 0, mu = 5, sigma = 1, nu = 1)}, main =
"Normal inverse-Gaussian density", ylab = "Probability density",
xlim = c(0,10))