distr (version 2.6)

Chisq-class: Class "Chisq"

Description

The chi-squared distribution with df$= n$ degrees of freedom has density $$f_n(x) = \frac{1}{{2}^{n/2} \Gamma (n/2)} {x}^{n/2-1} {e}^{-x/2}$$ for $x > 0$. The mean and variance are $n$ and $2n$.

The non-central chi-squared distribution with df$= n$ degrees of freedom and non-centrality parameter ncp $= \lambda$ has density $$ f(x) = e^{-\lambda / 2} \sum_{r=0}^\infty \frac{(\lambda/2)^r}{r!}\, f_{n + 2r}(x)$$ for $x \ge 0$. For integer $n$, this is the distribution of the sum of squares of $n$ normals each with variance one, $\lambda$ being the sum of squares of the normal means. C.f. rchisq

Arguments

Objects from the Class

Objects can be created by calls of the form Chisq(df, ncp). This object is a chi-squared distribution.

Slots

img
Object of class "Reals": The space of the image of this distribution has got dimension 1 and the name "Real Space".
param
Object of class "ChisqParameter": the parameter of this distribution (df and ncp), declared at its instantiation
r
Object of class "function": generates random numbers (calls function rchisq)
d
Object of class "function": density function (calls function dchisq)
p
Object of class "function": cumulative function (calls function pchisq)
q
Object of class "function": inverse of the cumulative function (calls function qchisq)
.withArith
logical: used internally to issue warnings as to interpretation of arithmetics
.withSim
logical: used internally to issue warnings as to accuracy
.logExact
logical: used internally to flag the case where there are explicit formulae for the log version of density, cdf, and quantile function
.lowerExact
logical: used internally to flag the case where there are explicit formulae for the lower tail version of cdf and quantile function
Symmetry
object of class "DistributionSymmetry"; used internally to avoid unnecessary calculations.

Extends

Class "ExpOrGammaOrChisq", directly. Class "AbscontDistribution", by class "ExpOrGammaOrChisq". Class "UnivariateDistribution", by class "AbscontDistribution". Class "Distribution", by class "UnivariateDistribution".

Is-Relations

By means of setIs, R ``knows'' that a distribution object obj of class "Chisq" with non-centrality 0 also is a Gamma distribution with parameters shape = df(obj)/2, scale = 2.

Methods

initialize
signature(.Object = "Chisq"): initialize method
df
signature(object = "Chisq"): returns the slot df of the parameter of the distribution
df<-
signature(object = "Chisq"): modifies the slot df of the parameter of the distribution
ncp
signature(object = "Chisq"): returns the slot ncp of the parameter of the distribution
ncp<-
signature(object = "Chisq"): modifies the slot ncp of the parameter of the distribution
+
signature(e1 = "Chisq", e2 = "Chisq"): For the chi-squared distribution we use its closedness under convolutions.

See Also

ChisqParameter-class AbscontDistribution-class Reals-class rchisq

Examples

Run this code
C <- Chisq(df = 1, ncp = 1) # C is a chi-squared distribution with df=1 and ncp=1.
r(C)(1) # one random number generated from this distribution, e.g. 0.2557184
d(C)(1) # Density of this distribution is 0.2264666 for x = 1.
p(C)(1) # Probability that x < 1 is 0.4772499.
q(C)(.1) # Probability that x < 0.04270125 is 0.1.
df(C) # df of this distribution is 1.
df(C) <- 2 # df of this distribution is now 2.
is(C, "Gammad") # no
C0 <- Chisq() # default: Chisq(df=1,ncp=0)
is(C0, "Gammad") # yes
as(C0,"Gammad")

Run the code above in your browser using DataLab