Learn R Programming

DPQmpfr (version 0.3-2)

dnt: Non-central t-Distribution Density

Description

dntJKBm is a fully Rmpfr-ified vectorized version of dntJKBf() from DPQ which implements the summation formulas of Johnson, Kotz and Balakrishnan (1995), (31.15) on page 516 and (31.15') on p.519, the latter being typo-corrected for a missing factor \(1 / j!\).

Usage

dntJKBm(x, df, ncp, log = FALSE, M = 1000)

Value

an mpfr vector of the same length as the maximum of the lengths of x, df, ncp.

Arguments

x, df, ncp

see R's dt(); note that each can be of class "mpfr".

log

as in dt(), a logical indicating if \(\log(f(x,*))\) should be returned instead of \(f(x,*)\).

M

the number of terms to be used, a positive integer.

Author

Martin Maechler

Details

How to choose M optimally has not been investigated yet and is probably also a function of the precision of the first three arguments (see getPrec from Rmpfr).

References

Johnson, N.L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions Vol~2, 2nd ed.; Wiley.
Chapter 31, Section 5 Distribution Function, p.514 ff

See Also

Examples

Run this code
require(Rmpfr)

## [not too large, as dntJKBm() is currently somewhat slow]
(mt  <- mpfr(tt  <- seq(0, 9, by =  1 ), 128))
(mcp <- mpfr(ncp <- seq(0, 5, by = 1/2), 128))
dt3R <- outer(tt, ncp, dt,   df = 3)
dt3M <- outer(mt, mcp, dntJKBm, df = 3, M = 128)# for speed

all.equal(dt3R, dt3M) # TRUE, and show difference
all.equal(dt3R, dt3M, tol=0) # 1.2e-12

Run the code above in your browser using DataLab