Calculates the ratio of Bessel K functions of different orders, but the same value of the argument.

1 | ```
besselRatio(x, nu, orderDiff, useExpScaled = 700)
``` |

`x` |
Numeric, |

`nu` |
Numeric. The order of the Bessel function in the denominator. |

`orderDiff` |
Numeric. The order of the numerator Bessel function minus the order of the denominator Bessel function. |

`useExpScaled` |
Numeric, |

Uses the function `besselK`

to calculate the ratio of two
modified Bessel function of the third kind whose orders are
different. The calculation of Bessel functions will underflow if the
value of *x* is greater than around 740. To avoid underflow the
exponentially-scaled Bessel functions can be returned by
`besselK`

. The ratio is actually unaffected by exponential
scaling since the scaling cancels across numerator and denominator.

The Bessel function ratio is useful in calculating moments of the generalized inverse Gaussian distribution, and hence also for the moments of the hyperbolic and generalized hyperbolic distributions.

The ratio

*K_(nu+k)(x)/K_nu(x)*

of two modified Bessel functions of the third kind whose orders differ
by *k*.

David Scott d.scott@auckland.ac.nz

`besselK`

, `gigMom`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
nus <- c(0:5, 10, 20)
x <- seq(1, 4, length.out = 11)
k <- 3
raw <- matrix(nrow = length(nus), ncol = length(x))
scaled <- matrix(nrow = length(nus), ncol = length(x))
compare <- matrix(nrow = length(nus), ncol = length(x))
for (i in 1:length(nus)){
for (j in 1:length(x)) {
raw[i,j] <- besselRatio(x[j], nus[i],
orderDiff = k)
scaled[i,j] <- besselRatio(x[j], nus[i],
orderDiff = k, useExpScaled = 1)
compare[i,j] <- raw[i,j]/scaled[i,j]
}
}
raw
scaled
compare
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.