Skip to content

numbas/numbas-extension-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Statistics extension for Numbas

This extension provides a load of statistical functions, wrapping the jStat library, as well as some extra functions not in jStat.

The data binning functions were written by Janet Cheung.

Functions

This list of functions contains descriptions copied from the jStat documentation. Click on the function name to see the original documentation.

There are also some extra functions not in jStat.

Descriptive statistics of a list of numbers

Returns the sum of the array vector.

Returns the sum squared of the array vector.

Returns the sum of squared errors of prediction of the array vector.

Returns the product of the array vector.

Returns the minimum value of the array vector.

Returns the maximum value of the array vector.

Returns the mean of the array vector.

Returns the mean squared error of the array vector.

Returns the geometric mean of the array vector.

Returns the median of the array vector.

Returns an array of partial sums in the sequence.

Returns an array of the successive differences of the array.

Returns the range of the array vector.

Returns the variance of the array vector. By default, the population variance is calculated. Passing true to flag indicates to compute the sample variance instead.

Returns the population variance of the array vector.

Returns the sample variance of the array vector.

Returns the standard deviation of the array vector. By default, the population standard deviation is returned. Passing true to flag returns the sample standard deviation.

Returns the population standard deviation of the array vector.

Returns the sample standard deviation of the array vector.

Returns the mean absolute deviation of the array vector.

Returns the median absolute deviation of the array vector.

Returns the coefficient of variation of the array vector.

Returns the quartiles of the array vector.

Correlation of two samples

Returns the covariance of the array1 and array2 vectors.

Returns the population correlation coefficient of the array1 and array2 vectors (Pearson's Rho).

Returns the standard deviation of the array vector. By default, the population standard deviation is returned. Passing true to flag returns the sample standard deviation.

Returns the variance of the array vector. By default, the population variance is calculated. Passing true to flag indicates to compute the sample variance instead.

Returns the mode of the array vector. If there are multiple modes then mode() will return all of them.

Distributions

Returns the value of x in the Beta distribution with parameters alpha and beta.

Returns the value of x in the cdf for the Beta distribution with parameters alpha and beta.

Returns the value of p in the inverse of the cdf for the Beta distribution with parameters alpha and beta.

Returns the mean of the Beta distribution with parameters alpha and beta.

Returns the median of the Beta distribution with parameters alpha and beta.

Returns the mode of the Beta distribution with parameters alpha and beta.

Returns a random number whose distribution is the Beta distribution with parameters alpha and beta.

Returns the variance of the Beta distribution with parameters alpha and beta.

Given x in the range [0, infinity), returns the probability density of the (central) F distribution at x.

Given x in the range [0, infinity), returns the cumulative probability density of the central F distribution. That is, jStat.centralF.cdf(2.5, 10, 20) will return the probability that a number randomly selected from the central F distribution with df1 = 10 and df2 = 20 will be less than 2.5.

Given p in [0, 1), returns the value of x for which the cumulative probability density of the central F distribution is p. That is, jStat.centralF.inv(p, df1, df2) = x if and only if jStat.centralF.inv(x, df1, df2) = p.

Returns the mean of the (Central) F distribution.

Returns the mode of the (Central) F distribution.

Returns a random number whose distribution is the (Central) F distribution.

Returns the variance of the (Central) F distribution.

Returns the value of x in the pdf of the Cauchy distribution with a location (median) of local and scale factor of scale.

Returns the value of x in the cdf of the Cauchy distribution with a location (median) of local and scale factor of scale.

Returns the value of p in the inverse of the cdf for the Cauchy distribution with a location (median) of local and scale factor of scale.

Returns the value of the median for the Cauchy distribution with a location (median) of local and scale factor of scale.

Returns the value of the mode for the Cauchy distribution with a location (median) of local and scale factor of scale.

Returns a random number whose distribution is the Cauchy distribution with a location (median) of local and scale factor of scale.

Returns the value of x in the pdf of the Chi Square distribution with dof degrees of freedom.

Returns the value of x in the cdf of the Chi Square distribution with dof degrees of freedom.

Returns the value of x in the inverse of the cdf for the Chi Square distribution with dof degrees of freedom.

Returns the value of the mean for the Chi Square distribution with dof degrees of freedom.

Returns the value of the median for the Chi Square distribution with dof degrees of freedom.

Returns the value of the mode for the Chi Square distribution with dof degrees of freedom.

Returns a random number whose distribution is the Chi Square distribution with dof degrees of freedom.

Returns the value of the variance for the Chi Square distribution with dof degrees of freedom.

Returns the value of x in the pdf of the Exponential distribution with the parameter rate (lambda).

Returns the value of x in the cdf of the Exponential distribution with the parameter rate (lambda).

Returns the value of p in the inverse of the cdf for the Exponential distribution with the parameter rate (lambda).

Returns the value of the mean for the Exponential distribution with the parameter rate (lambda).

Returns the value of the median for the Exponential distribution with the parameter rate (lambda)

Returns the value of the mode for the Exponential distribution with the parameter rate (lambda).

Returns a random number whose distribution is the Exponential distribution with the parameter rate (lambda).

Returns the value of the variance for the Exponential distribution with the parameter rate (lambda).

Returns the value of x in the pdf of the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

Returns the value of x in the cdf of the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

Returns the value of p in the inverse of the cdf for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

Returns the value of the mean for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

Returns the value of the mode for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

Returns a random number whose distribution is the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

Returns the value of the variance for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

Returns the value of x in the pdf of the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

Returns the value of x in the cdf of the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

Returns the value of p in the inverse of the cdf for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

Returns the value of the mean for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

Returns the value of the mode for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

Returns a random number whose distribution is the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

Returns the value of the variance for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

Returns the value of x in the pdf of the Kumaraswamy distribution with parameters a and b.

Returns the value of x in the cdf of the Kumaraswamy distribution with parameters alpha and beta.

Returns the value of p in the inverse of the pdf for the Kumaraswamy distribution with parametres alpha and beta.

Returns the value of the mean of the Kumaraswamy distribution with parameters alpha and beta.

Returns the value of the median of the Kumaraswamy distribution with parameters alpha and beta.

Returns the value of the mode of the Kumaraswamy distribution with parameters alpha and beta.

Returns the value of the variance of the Kumaraswamy distribution with parameters alpha and beta.

Returns the value of x in the pdf of the Log-normal distribution with paramters mu (mean) and sigma (standard deviation).

Returns the value of x in the cdf of the Log-normal distribution with paramters mu (mean) and sigma (standard deviation).

Returns the value of x in the inverse of the cdf for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

Returns the value of the mean for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

Returns the value of the median for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

Returns the value of the mode for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

Returns a random number whose distribution is the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

Returns the value of the variance for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

Returns the value of x in the pdf of the Normal distribution with parameters mean and std (standard deviation).

Returns the value of x in the cdf of the Normal distribution with parameters mean and std (standard deviation).

Returns the value of p in the inverse cdf for the Normal distribution with parameters mean and std (standard deviation).

Returns the value of the mean for the Normal distribution with parameters mean and std (standard deviation).

Returns the value of the median for the Normal distribution with parameters mean and std (standard deviation).

Returns the value of the mode for the Normal distribution with parameters mean and std (standard deviation).

Returns a random number whose distribution is the Normal distribution with parameters mean and std (standard deviation).

Returns the value of the variance for the Normal distribution with parameters mean and std (standard deviation).

Returns the value of x in the pdf of the Pareto distribution with parameters scale (x<sub>m</sub>) and shape (alpha).

Returns the value of x in the cdf of the Pareto distribution with parameters scale (x<sub>m</sub>) and shape (alpha).

Returns the inverse of the Pareto distribution with probability p, scale, shape.

Returns the value of the mean of the Pareto distribution with parameters scale (x<sub>m</sub>) and shape (alpha).

Returns the value of the median of the Pareto distribution with parameters scale (x<sub>m</sub>) and shape (alpha).

Returns the value of the mode of the Pareto distribution with parameters scale (x<sub>m</sub>) and shape (alpha).

Returns the value of the variance of the Pareto distribution with parameters scale (x<sub>m</sub>) and shape (alpha).

Returns the value of x in the pdf of the Student's T distribution with dof degrees of freedom.

Returns the value of x in the cdf of the Student's T distribution with dof degrees of freedom.

Returns the value of p in the inverse of the cdf for the Student's T distribution with dof degrees of freedom.

Returns the value of the mean of the Student's T distribution with dof degrees of freedom.

Returns the value of the median of the Student's T distribution with dof degrees of freedom.

Returns the value of the mode of the Student's T distribution with dof degrees of freedom.

Returns a random number whose distribution is the Student's T distribution with dof degrees of freedom.

Returns the value of the variance for the Student's T distribution with dof degrees of freedom.

Returns the value x in the pdf for the Weibull distribution with parameters scale (lambda) and shape (k).

Returns the value x in the cdf for the Weibull distribution with parameters scale (lambda) and shape (k).

Returns the value of x in the inverse of the cdf for the Weibull distribution with parameters scale (lambda) and shape (k).

Returns the value of the mean of the Weibull distribution with parameters scale (lambda) and shape (k).

Returns the value of the median of the Weibull distribution with parameters scale (lambda) and shape (k).

Returns the mode of the Weibull distribution with parameters scale (lambda) and shape (k).

Returns a random number whose distribution is the Weibull distribution with parameters scale (lambda) and shape (k).

Returns the variance of the Weibull distribution with parameters scale (lambda) and shape (k).

Returns the value of x in the pdf of the Uniform distribution from a to b.

Returns the value of x in the cdf of the Uniform distribution from a to b.

Returns the inverse of the uniform.cdf function; i.e. the value of x for which uniform.cdf(x, a, b) == p.

Returns the value of the mean of the Uniform distribution from a to b.

Returns the value of the median of the Uniform distribution from a to b.

Returns the value of the mode of the Uniform distribution from a to b.

Returns a random number whose distribution is the Uniform distribution from a to b.

Returns the variance of the Uniform distribution from a to b.

Returns the value of k in the pdf of the Binomial distribution with parameters n and p.

Returns the value of k in the cdf of the Binomial distribution with parameters n and p.

Returns the value of k in the pdf of the Negative Binomial distribution with parameters n and p.

Returns the value of x in the cdf of the Negative Binomial distribution with parameters n and p.

Returns the value of k in the pdf of the Hypergeometric distribution with parameters N (the population size), m (the success rate), and n (the number of draws).

Returns the value of x in the cdf of the Hypergeometric distribution with parameters N (the population size), m (the success rate), and n (the number of draws).

Returns the value of k in the pdf of the Poisson distribution with parameter l (lambda).

Returns the value of x in the cdf of the Poisson distribution with parameter l (lambda).

Returns a random number whose distribution is the Poisson distribution with rate parameter l (lamda)

Returns the value of x in the pdf of the Triangular distribution with the parameters a, b, and c.

Returns the value of x in the cdf of the Triangular distribution with the parameters a, b, and c.

Returns the value of the mean of the Triangular distribution with the parameters a, b, and c.

Returns the value of the median of the Triangular distribution with the parameters a, b, and c.

Returns the value of the mode of the Triangular distribution with the parameters a, b, and c.

Returns a random number whose distribution is the Triangular distribution with the parameters a, b, and c.

Returns the value of the variance of the Triangular distribution with the parameters a, b, and c.

Statistical Tests

Returns the z-score of value given the data from array. flag===true denotes use of the sample standard deviation.

Returns the z-score of value given the data from array. flag===true denotes use of the sample standard deviation.

Returns the p-value of value given the data from array. sides is an integer value 1 or 2 denoting a one or two sided z-test. If sides is not specified the test defaults to a two sided z-test. flag===true denotes the use of the sample standard deviation.

Returns the p-value of value given the data from array. sides is an integer value 1 or 2 denoting a one or two sided z-test. If sides is not specified the test defaults to a two sided z-test. flag===true denotes the use of the sample standard deviation.

Returns the t-score of value given the data from array.

Returns the t-score of value given the data from array.

Returns the p-value of value given the data in array. sides is an integer value 1 or 2 denoting a one or two sided t-test. If sides is not specified the test defaults to a two sided t-test.

Returns the p-value of value given the data in array. sides is an integer value 1 or 2 denoting a one or two sided t-test. If sides is not specified the test defaults to a two sided t-test.

Returns the p-value of value given the data in array. sides is an integer value 1 or 2 denoting a one or two sided t-test. If sides is not specified the test defaults to a two sided t-test.

Returns the f-score of an ANOVA on the arrays.

Returns the p-value of the f-statistic from the ANOVA test on the arrays.

Returns the p-value for the fscore f-score with a df1 numerator degrees of freedom and a df2 denominator degrees of freedom.

Confidence intervals

Returns a 1-alpha confidence interval for value given a normal distribution in the data from array.

Returns a 1-alpha confidence interval for value given a normal distribution in the data from array.

Returns a 1-alpha confidence interval for value given the data from array.

Returns a 1-alpha confidence interval for value given the data from array.

Special functions

Evaluates the Beta function at (x,y).

Evaluates the log Beta function at (x,y).

Returns the continued fraction for the incomplete Beta function with parameters a and b modified by Lentz's method evaluated at x.

Returns the inverse of the incomplete Beta function evaluated at (p,a,b).

Returns the incomplete Beta function evaluated at (x,a,b).

Returns the Log-Gamma function evaluated at x.

Returns the Gamma function evaluated at x. This is sometimes called the 'complete' gamma function.

Returns the lower incomplete gamma function evaluated at (a,x). This function is usually written with a lower case greek gamma character, and is one of the two incomplete gamma functions.

Returns the natural log factorial of n.

Returns the factorial of n.

Returns the number of combinations of n, m.

Returns the number of permutations of n, m.

Returns the inverse of the lower regularized incomplete Gamma function evaluated at (p,a). This function is the inverse of lowerRegularizedGamma(x, a).

Returns the error function evaluated at x.

Returns the complementary error function evaluated at x.

Returns the inverse of the complementary error function evaluated at p.

Returns a normal deviate (mean 0 and standard deviation 1).

Returns a Gamma deviate by the method of Marsaglia and Tsang.

Data binning

bin(data, num_bins, [range])

Put the list of numbers data into bins of equal size. The number of bins is given by num_bins. If range is given, then the bins span that range; otherwise they span the same range as the given data, with the first bin starting at the minimum value and the last bin ending at the maximum.

Examples:

  • bin([1,2,3,4,5,6,7], 3)[ [1,2], [3,4], [5,6,7] ]
  • bin([1,2,3,4,5,6,7], 3, 1..10)[ [1,2,3], [4,5,6], [7] ]
  • bin([1,7,9], 3)[ [1], [], [7,9] ]

About

A Numbas extension providing a wrapper around the jStat library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published