# Ratio of Bessel K Functions

### Description

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

### Usage

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

### Arguments

`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, |

### Details

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.

### Value

The ratio

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

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

### Author(s)

David Scott d.scott@auckland.ac.nz

### See Also

`besselK`

, `gigMom`

### Examples

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
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.