# Chi-squared Random Samples

Example Data | 244 | 238 | 1 |

Help | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

## The (non-central) $\chi^2$ Distribution## DescriptionDensity, distribution function, quantile function and random
generation for the chi-squared ( ## Usagedchisq(x, df, ncp = 0, log = FALSE) pchisq(q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) qchisq(p, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) rchisq(n, df, ncp = 0) ## Arguments
## DetailsThe chi-squared distribution with
for The non-central chi-squared distribution with
for Note that the degrees of freedom Note that ## Value
Invalid arguments will result in return value The length of the result is determined by The numerical arguments other than ## NoteSupplying The code for non-zero ## SourceThe central cases are computed via the gamma distribution. The non-central The non-central Ding, C. G. (1992)
Algorithm AS275: Computing the non-central chi-squared
distribution function. which computes the lower tail only (so the upper tail suffers from cancellation and a warning will be given when this is likely to be significant). The non-central ## ReferencesBecker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995)
## Examplesrequire(graphics) dchisq(1, df = 1:3) pchisq(1, df = 3) pchisq(1, df = 3, ncp = 0:4) # includes the above x <- 1:10 ## Chi-squared(df = 2) is a special exponential distribution all.equal(dchisq(x, df = 2), dexp(x, 1/2)) all.equal(pchisq(x, df = 2), pexp(x, 1/2)) ## non-central RNG -- df = 0 with ncp > 0: Z0 has point mass at 0! Z0 <- rchisq(100, df = 0, ncp = 2.) graphics::stem(Z0) ## visual testing ## do P-P plots for 1000 points at various degrees of freedom L <- 1.2; n <- 1000; pp <- ppoints(n) op <- par(mfrow = c(3,3), mar = c(3,3,1,1)+.1, mgp = c(1.5,.6,0), oma = c(0,0,3,0)) for(df in 2^(4*rnorm(9))) { plot(pp, sort(pchisq(rr <- rchisq(n, df = df, ncp = L), df = df, ncp = L)), ylab = "pchisq(rchisq(.),.)", pch = ".") mtext(paste("df = ", formatC(df, digits = 4)), line = -2, adj = 0.05) abline(0, 1, col = 2) } mtext(expression("P-P plots : Noncentral "* chi^2 *"(n=1000, df=X, ncp= 1.2)"), cex = 1.5, font = 2, outer = TRUE) par(op) ## "analytical" test lam <- seq(0, 100, by = .25) p00 <- pchisq(0, df = 0, ncp = lam) p.0 <- pchisq(1e-300, df = 0, ncp = lam) stopifnot(all.equal(p00, exp(-lam/2)), all.equal(p.0, exp(-lam/2))) |

Recent Queries With This Operation |
---|

No queries made on this operation yet. |

Recent Queries | App/Dataset | By | Date |
---|---|---|---|

Picostat Output - Numerical Summaries | R Dataset / Package datasets / quakes | wicetram | October 24, 2020 - 3:20 PM |

Picostat Output - Visual Summaries | R Dataset / Package datasets / quakes | wicetram | October 24, 2020 - 3:17 PM |

Picostat Output - Visual Summaries | R Dataset / Package datasets / quakes | wicetram | October 24, 2020 - 3:15 PM |

Picostat Output - Cumulative Frequency Histogram | R Dataset / Package datasets / quakes | wicetram | October 24, 2020 - 3:12 PM |

Picostat Output - Boxplot | R Dataset / Package datasets / quakes | wicetram | October 24, 2020 - 3:12 PM |

#### Pagination

Title | Authored on | Content type |
---|---|---|

R Dataset / Package COUNT / mdvis | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package DAAG / hills2000 | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package ISLR / Carseats | March 9, 2018 - 1:06 PM | Dataset |

OpenIntro Statistics Dataset - antibiotics | August 9, 2020 - 12:25 PM | Dataset |

R Dataset / Package car / Sahlins | March 9, 2018 - 1:06 PM | Dataset |