Learn R Programming

EnvStats (version 2.4.0)

Chi: The Chi Distribution

Description

Density, distribution function, quantile function, and random generation for the chi distribution.

Usage

dchi(x, df)
  pchi(q, df)
  qchi(p, df)
  rchi(n, df)

Arguments

x

vector of (positive) quantiles.

q

vector of (positive) quantiles.

p

vector of probabilities between 0 and 1.

n

sample size. If length(n) is larger than 1, then length(n) random values are returned.

df

vector of (positive) degrees of freedom (> 0). Non-integer values are allowed.

Value

density (dchi), probability (pchi), quantile (qchi), or random sample (rchi) for the chi distribution with df degrees of freedom.

Details

Elements of x, q, p, or df that are missing will cause the corresponding elements of the result to be missing.

The chi distribution with \(n\) degrees of freedom is the distribution of the positive square root of a random variable having a chi-squared distribution with \(n\) degrees of freedom.

The chi density function is given by: $$f(x, \nu) = g(x^2, \nu) 2x, x > 0$$ where \(g(x,\nu)\) denotes the density function of a chi-square random variable with \(n\) degrees of freedom.

References

Forbes, C., M. Evans, N. Hastings, and B. Peacock. (2011). Statistical Distributions. Fourth Edition. John Wiley and Sons, Hoboken, NJ.

Johnson, N. L., S. Kotz, and N. Balakrishnan. (1995). Continuous Univariate Distributions, Volume 1. Second Edition. John Wiley and Sons, New York.

See Also

Chisquare, Normal, predIntNorm, Probability Distributions and Random Numbers.

Examples

Run this code
# NOT RUN {
  # Density of a chi distribution with 4 degrees of freedom, evaluated at 3:

  dchi(3, 4) 
  #[1] 0.1499715

  #----------

  # The 95'th percentile of a chi distribution with 10 degrees of freedom:

  qchi(.95, 10) 
  #[1] 4.278672

  #----------

  # The cumulative distribution function of a chi distribution with 
  # 5 degrees of freedom evaluated at 3:

  pchi(3, 5) 
  #[1] 0.8909358

  #----------

  # A random sample of 2 numbers from a chi distribution with 7 degrees of freedom. 
  # (Note: the call to set.seed simply allows you to reproduce this example.)

  set.seed(20) 
  rchi(2, 7) 
  #[1] 3.271632 2.035179
# }

Run the code above in your browser using DataLab