Accessing Common Distributions When Writing JavaScript in Q

From Q
Jump to navigation Jump to search

Please note: the code snippets on this page require Q 4.8.3 or later.

This page displays JavaScript methods that calculate densities, cumulative distributions and quantiles and generate random samples from common discrete and continuous distributions. These methods are part of the jStat statistical library and can be used in QScripts, Rules and JavaScript Variables in Q.

Beta distribution

Density

Returns the value of the density (pdf) at x of the Beta distribution with parameters alpha and beta:

jStat.beta.pdf(x, alpha, beta)

Cumulative distribution function

Returns the value of the cdf at x of the Beta distribution with parameters alpha and beta:

jStat.beta.cdf(x, alpha, beta)

Quantile function

Returns the value of the quantile function at p of the Beta distribution with parameters alpha and beta:

jStat.beta.inv(p, alpha, beta)

Random sampling

Returns a random sample from the Beta distribution with parameters alpha and beta:

jStat.beta.sample(alpha, beta)

Binomial distribution

Density

Returns the probability of k from the Binomial distribution with parameters n and p:

jStat.binomial.pdf(k, n, p)

Cumulative distribution function

Returns the value of the cdf at k of the Binomial distribution with parameters n and p:

jStat.binomial.cdf(k, n, p)

Cauchy distribution

Density

Returns the value of the density (pdf) at x of the Cauchy distribution with parameters location and scale:

jStat.cauchy.pdf(x, location, scale)

Cumulative distribution function

Returns the value of the cdf at x of the Cauchy distribution with parameters location and scale:

jStat.cauchy.cdf(x, location, scale)

Quantile function

Returns the value of the quantile function at p of the Cauchy distribution with parameters location and scale:

jStat.cauchy.inv(p, location, scale)

Random sampling

Returns a random sample from the Cauchy distribution with parameters location and scale:

jStat.cauchy.sample(location, scale)

Chi-squared distribution

Density

Returns the value of the density (pdf) at x of the chi-squared distribution with parameter df (degrees of freedom):

jStat.chisquare.pdf(x, df)

Cumulative distribution function

Returns the value of the cdf at x of the chi-squared distribution with parameter df (degrees of freedom):

jStat.chisquare.cdf(x, df)

Quantile function

Returns the value of the quantile function at p of the chi-squared distribution with parameter df (degrees of freedom):

jStat.chisquare.inv(p, df)

Random sampling

Returns a random sample from the chi-squared distribution with parameter df (degrees of freedom):

jStat.chisquare.sample(df)

Exponential distribution

Density

Returns the value of the density (pdf) at x of the exponential distribution with parameter rate:

jStat.exponential.pdf(x, rate)

Cumulative distribution function

Returns the value of the cdf at x of the exponential distribution with parameter rate:

jStat.exponential.cdf(x, rate)

Quantile function

Returns the value of the quantile function at p of the exponential distribution with parameter rate:

jStat.exponential.inv(p, rate)

Random sampling

Returns a random sample from the exponential distribution with parameter rate:

jStat.exponential.sample(rate)

F-distribution

Density

Returns the value of the density (pdf) at x of the F-distribution with parameters df1 and df2 (degrees of freedom):

jStat.centralF.pdf(x, df1, df2)

Cumulative distribution function

Returns the value of the cdf at x of the F-distribution with parameters df1 and df2 (degrees of freedom):

jStat.centralF.cdf(x, df1, df2)

Quantile function

Returns the value of the quantile function at p of the F-distribution with parameters df1 and df2 (degrees of freedom):

jStat.centralF.inv(p, df1, df2)

Random sampling

Returns a random sample from the F-distribution with parameters df1 and df2 (degrees of freedom):

jStat.centralF.sample(df1, df2)

Gamma distribution

Density

Returns the value of the density (pdf) at x of the gamma distribution with parameters shape and scale:

jStat.gamma.pdf(x, shape, scale)

Cumulative distribution function

Returns the value of the cdf at x of the gamma distribution with parameters shape and scale:

jStat.gamma.cdf(x, shape, scale)

Quantile function

Returns the value of the quantile function at p of the gamma distribution with parameters shape and scale:

jStat.gamma.inv(p, shape, scale)

Random sampling

Returns a random sample from the gamma distribution with parameters shape and scale:

jStat.gamma.sample(shape, scale)

Hypergeometric distribution

Density

Returns the probability of k from the hypergeometric distribution with parameters N (the population size), m (the success rate), and n (the number of draws):

jStat.hypgeom.pdf(k, N, m, n)

Cumulative distribution function

Returns the value of the cdf at k of the hypergeometric distribution with parameters N (the population size), m (the success rate), and n (the number of draws):

jStat.hypgeom.cdf(k, N, m, n)

Log-normal distribution

Density

Returns the value of the density (pdf) at x of the log-normal distribution with parameters mu and sigma:

jStat.lognormal.pdf(x, mu, sigma)

Cumulative distribution function

Returns the value of the cdf at x of the gamma distribution with parameters mu and sigma:

jStat.lognormal.cdf(x, mu, sigma)

Quantile function

Returns the value of the quantile function at p of the gamma distribution with parameters mu and sigma:

jStat.lognormal.inv(p, mu, sigma)

Random sampling

Returns a random sample from the gamma distribution with parameters mu and sigma:

jStat.lognormal.sample(mu, sigma)

Negative binomial distribution

Density

Returns the probability of k from the negative binomial distribution with parameters r and p:

jStat.negbin.pdf(k, r, p)

Cumulative distribution function

Returns the value of the cdf at k of the negative binomial distribution with parameters r and p:

jStat.negbin.cdf(k, r, p)

Normal distribution

Density

Returns the value of the density (pdf) at x of the normal distribution with parameters mean and std (standard deviation):

jStat.normal.pdf(x, mean, std)

Cumulative distribution function

Returns the value of the cdf at x of the normal distribution with parameters mean and std (standard deviation):

jStat.normal.cdf(x, mean, std)

Quantile function

Returns the value of the quantile function at p of the normal distribution with parameters mean and std (standard deviation):

jStat.normal.inv(p, mean, std)

Random sampling

Returns a random sample from the normal distribution with parameters mean and std (standard deviation):

jStat.normal.sample(mean, std)

Poisson distribution

Density

Returns the probability of k from the Poisson distribution with parameter lambda:

jStat.poisson.pdf(k, lambda)

Cumulative distribution function

Returns the value of the cdf at k of the Poisson distribution with parameter lambda:

jStat.poisson.cdf(k, lambda)

Student's t-distribution

Density

Returns the value of the density (pdf) at x of the Student's t-distribution with parameter df (degrees of freedom):

jStat.studentt.pdf(x, df)

Cumulative distribution function

Returns the value of the cdf at x of the Student's t-distribution with parameter df (degrees of freedom):

jStat.studentt.cdf(x, df)

Quantile function

Returns the value of the quantile function at p of the Student's t-distribution with parameter df (degrees of freedom):

jStat.studentt.inv(p, df)

Random sampling

Returns a random sample from the Student's t-distribution with parameter df (degrees of freedom):

jStat.studentt.sample(df)

Uniform distribution

Density

Returns the value of the density (pdf) at x of the uniform distribution with parameters min and max:

jStat.uniform.pdf(x, min, max)

Cumulative distribution function

Returns the value of the cdf at x of the uniform distribution with parameters min and max:

jStat.uniform.cdf(x, min, max)

Random sampling

Returns a random sample from the uniform distribution with parameters min and max:

jStat.uniform.sample(min, max)

Weibull distribution

Density

Returns the value of the density (pdf) at x of the Weibull distribution with parameters scale and shape:

jStat.weibull.pdf(x, scale, shape)

Cumulative distribution function

Returns the value of the cdf at x of the Weibull distribution with parameters scale and shape:

jStat.weibull.cdf(x, scale, shape)

Quantile function

Returns the value of the quantile function at p of the Weibull distribution with parameters scale and shape:

jStat.weibull.inv(p, scale, shape)

Random sampling

Returns a random sample from the Weibull distribution with parameters scale and shape:

jStat.weibull.sample(scale, shape)

See also