Package jdistlib
Class NonCentralChiSquare
java.lang.Object
jdistlib.generic.GenericDistribution
jdistlib.NonCentralChiSquare
-
Field Summary
FieldsFields inherited from class jdistlib.generic.GenericDistribution
random -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecumulative(double p, boolean lower_tail, boolean log_p) static final doublecumulative(double x, double df, double ncp, boolean lower_tail, boolean log_p) static final doublecumulative_raw(double x, double f, double theta, double errmax, double reltol, int itrmax, boolean lower_tail, boolean log_p) doubledensity(double x, boolean log) static final doubledensity(double x, double df, double ncp, boolean give_log) doublequantile(double q, boolean lower_tail, boolean log_p) static final doublequantile(double p, double df, double ncp, boolean lower_tail, boolean log_p) doublerandom()static final doublerandom(double df, double lambda, RandomEngine random) According to Hans R.static final double[]random(int n, double df, double lambda, RandomEngine random) Methods inherited from class jdistlib.generic.GenericDistribution
copyBackward, cumulative, cumulative, cumulative, cumulative_hazard, cumulative_hazard, cumulativeInto, density, density, densityInto, getRandomEngine, hazard, hazard, inverse_survival, inverse_survival, quantile, quantile, quantile, quantileInto, random, random, randomInto, setRandomEngine, survival, survival, survival
-
Field Details
-
df
protected double df -
ncp
protected double ncp
-
-
Constructor Details
-
NonCentralChiSquare
public NonCentralChiSquare(double df, double ncp)
-
-
Method Details
-
density
public static final double density(double x, double df, double ncp, boolean give_log) -
cumulative_raw
public static final double cumulative_raw(double x, double f, double theta, double errmax, double reltol, int itrmax, boolean lower_tail, boolean log_p) -
cumulative
public static final double cumulative(double x, double df, double ncp, boolean lower_tail, boolean log_p) -
quantile
public static final double quantile(double p, double df, double ncp, boolean lower_tail, boolean log_p) -
random
According to Hans R. Kuensch's suggestion (30 sep 2002): It should be easy to do the general case (ncp > 0) by decomposing it as the sum of a central chisquare with df degrees of freedom plus a noncentral chisquare with zero degrees of freedom (which is a Poisson mixture of central chisquares with integer degrees of freedom), see Formula (29.5b-c) in Johnson, Kotz, Balakrishnan (1995). The noncentral chisquare with arbitary degrees of freedom is of interest for simulating the Cox-Ingersoll-Ross model for interest rates in finance. R code that works is rchisq0 <- function(n, ncp) { p <- 0 < (K <- rpois(n, lambda = ncp / 2)) r <- numeric(n) r[p] <- rchisq(sum(p), df = 2*K[p]) r } rchisq <- function(n, df, ncp=0) { if(missing(ncp)) .Internal(rchisq(n, df)) else rchisq0(n, ncp) + .Internal(rchisq(n, df)) } -
random
-
density
public double density(double x, boolean log) - Specified by:
densityin classGenericDistribution
-
cumulative
public double cumulative(double p, boolean lower_tail, boolean log_p) - Specified by:
cumulativein classGenericDistribution
-
quantile
public double quantile(double q, boolean lower_tail, boolean log_p) - Specified by:
quantilein classGenericDistribution
-
random
public double random()- Specified by:
randomin classGenericDistribution
-