Title: | The Chi Distribution |
---|---|
Description: | Light weight implementation of the standard distribution functions for the chi distribution, wrapping those for the chi-squared distribution in the stats package. |
Authors: | David Kahle [aut, cre, cph] |
Maintainer: | David Kahle <[email protected]> |
License: | GPL-2 |
Version: | 0.0 |
Built: | 2024-11-09 05:07:20 UTC |
Source: | https://github.com/dkahle/chi |
Density, distribution function, quantile function and random generation for the chi distribution.
dchi(x, df, ncp = 0, log = FALSE) pchi(q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) qchi(p, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) rchi(n, df, ncp = 0)
dchi(x, df, ncp = 0, log = FALSE) pchi(q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) qchi(p, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) rchi(n, df, ncp = 0)
x , q
|
vector of quantiles. |
df |
degrees of freedom (non-negative, but can be non-integer). |
ncp |
non-centrality parameter (non-negative). |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are P[X <= x] otherwise, P[X > x]. |
p |
vector of probabilities. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required. |
The functions (d/p/q/r)chi simply wrap those of the standard
(d/p/q/r)chisq R implementation, so look at, say,
dchisq
for details.
dchisq
; these functions just wrap the
(d/p/q/r)chisq functions.
s <- seq(0, 5, .01) plot(s, dchi(s, 7), type = 'l') f <- function(x) dchi(x, 7) q <- 2 integrate(f, 0, q) (p <- pchi(q, 7)) qchi(p, 7) # = q mean(rchi(1e5, 7) <= q) samples <- rchi(1e5, 7) plot(density(samples)) curve(f, add = TRUE, col = "red")
s <- seq(0, 5, .01) plot(s, dchi(s, 7), type = 'l') f <- function(x) dchi(x, 7) q <- 2 integrate(f, 0, q) (p <- pchi(q, 7)) qchi(p, 7) # = q mean(rchi(1e5, 7) <= q) samples <- rchi(1e5, 7) plot(density(samples)) curve(f, add = TRUE, col = "red")
Density, distribution function, quantile function and random generation for the inverse chi distribution.
dinvchi(x, df, ncp = 0, log = FALSE) pinvchi(q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) qinvchi(p, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) rinvchi(n, df, ncp = 0)
dinvchi(x, df, ncp = 0, log = FALSE) pinvchi(q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) qinvchi(p, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) rinvchi(n, df, ncp = 0)
x , q
|
vector of quantiles. |
df |
degrees of freedom (non-negative, but can be non-integer). |
ncp |
non-centrality parameter (non-negative). |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are P[X <= x] otherwise, P[X > x]. |
p |
vector of probabilities. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required. |
s <- seq(0, 2, .01) plot(s, dinvchi(s, 7), type = 'l') f <- function(x) dinvchi(x, 7) q <- .5 integrate(f, 0, q) (p <- pinvchi(q, 7)) qinvchi(p, 7) # = q mean(rinvchi(1e5, 7) <= q) samples <- rinvchi(1e5, 7) plot(density(samples)) curve(f, add = TRUE, col = "red")
s <- seq(0, 2, .01) plot(s, dinvchi(s, 7), type = 'l') f <- function(x) dinvchi(x, 7) q <- .5 integrate(f, 0, q) (p <- pinvchi(q, 7)) qinvchi(p, 7) # = q mean(rinvchi(1e5, 7) <= q) samples <- rinvchi(1e5, 7) plot(density(samples)) curve(f, add = TRUE, col = "red")