## org.jscience.mathematics.statistics Class StatisticsUtils

```java.lang.Object org.jscience.mathematics.statistics.StatisticsUtils
```

`public final class StatisticsUtilsextends java.lang.Object`

This class defines a collection of static functions that are useful in probability.

Field Summary
`static int` `WITH_REPLACEMENT`
DOCUMENT ME!
`static int` `WITHOUT_REPLACEMENT`
DOCUMENT ME!

Constructor Summary
`StatisticsUtils()`

Method Summary
`static double` ```beta(double a, double b)```
This method returns an approximation to the beta function.
`static double` ```betaCDF(double x, double a, double b)```
The method computes the beta cumulative distribution function.
`static double` ```combinations(double n, int k)```
This method computes the number of combinations of a specified number of objects chosen from a population of a specified size.
`static double` `factorial(int k)`
This method computes the factorial function, the number of permutations of a specified number of objects.
`static double` `gamma(double x)`
This method computes the gamma function.
`static double` ```gammaCDF(double x, double a)```
This method computes the cumulative distribution function of the gamma distribution with a specified shape parameter and scale parameter 1.
`static int` ```getIndex(int i, int n)```
This method returns an index between 0 and n - 1, for use in error correcting in arrays.
`static double[]` `getProbabilities(double[] a)`
This method takes an array of numbers and returns a probability array (nonnegatie numbers that sum to 1).
`static double` `getProbability(double p)`
This method takes a real number and converts it to a probability (a number between 0 and 1).
`static int[]` ```getSample(int[] p, int n, int t)```
This method computes a sample of a specified size from a specified population and of a specified type (with or without replacement).
`static int[]` ```getSample(int m, int n, int t)```
This method computes a sample of a specified size from a population of the form 1, 2, ..., m
`static boolean` `isReal(double x)`
This class method tests to see if a specified number is real.
`static double` `logGamma(double x)`
This method computes the log of the gamma function.
`static double` ```permutations(double n, int k)```
This method computes the number of permutations of a specified number of objects chosen from a population of a specified number of objects.
`static double[]` `sort(double[] a)`
This method sorts an array of doubles.
`static int[]` `sort(int[] a)`
This method sorts an array of integers.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WITHOUT_REPLACEMENT

`public static final int WITHOUT_REPLACEMENT`
DOCUMENT ME!

Constant Field Values

### WITH_REPLACEMENT

`public static final int WITH_REPLACEMENT`
DOCUMENT ME!

Constant Field Values
Constructor Detail

### StatisticsUtils

`public StatisticsUtils()`
Method Detail

### getProbabilities

`public static double[] getProbabilities(double[] a)`
This method takes an array of numbers and returns a probability array (nonnegatie numbers that sum to 1). Negative numbers in the original array are converted to zeros, and the remaining numbers scaled by the sum of the numbers, assuming that not all of the original numbers are 0. In the last case, the method returns the uniform probabiltiy array.

Parameters:
`a` - the array of numbers
Returns:
the probability array

### getProbability

`public static double getProbability(double p)`
This method takes a real number and converts it to a probability (a number between 0 and 1).

Parameters:
`p` - the given number
Returns:
the probability.

### getIndex

```public static int getIndex(int i,
int n)```
This method returns an index between 0 and n - 1, for use in error correcting in arrays.

Parameters:
`i` - the given index
`n` - the specified size of the array
Returns:
the verified index between 0 and n - 1

### permutations

```public static double permutations(double n,
int k)```
This method computes the number of permutations of a specified number of objects chosen from a population of a specified number of objects.

Parameters:
`n` - the population size
`k` - the sample size
Returns:
the number of ordered samples

### factorial

`public static double factorial(int k)`
This method computes the factorial function, the number of permutations of a specified number of objects.

Parameters:
`k` - the number of objects
Returns:
the number of permutations of the objects

### combinations

```public static double combinations(double n,
int k)```
This method computes the number of combinations of a specified number of objects chosen from a population of a specified size.

Parameters:
`n` - the population size
`k` - the sample size
Returns:
the number of unordered samples

### logGamma

`public static double logGamma(double x)`
This method computes the log of the gamma function.

Parameters:
`x` - a positive number
Returns:
the log of the gamma function at x

### gamma

`public static double gamma(double x)`
This method computes the gamma function.

Parameters:
`x` - a positive number
Returns:
the gamma function at x

### gammaCDF

```public static double gammaCDF(double x,
double a)```
This method computes the cumulative distribution function of the gamma distribution with a specified shape parameter and scale parameter 1.

Parameters:
`x` - a positive number
`a` - the shape parameter
Returns:
the cumulative probability at x

### betaCDF

```public static double betaCDF(double x,
double a,
double b)```
The method computes the beta cumulative distribution function.

Parameters:
`x` - a number between 0 and 1
`a` - the left paramter
`b` - the right parameter
Returns:
the beta cumulative probability at x

### beta

```public static double beta(double a,
double b)```
This method returns an approximation to the beta function.

Parameters:
`a` - the left value
`b` - the right value
Returns:
the beta function at (a, b)

### getSample

```public static int[] getSample(int[] p,
int n,
int t)```
This method computes a sample of a specified size from a specified population and of a specified type (with or without replacement).

Parameters:
`p` - the population
`n` - the sample size
`t` - the type (0 without replacement, 1 with replacemen);
Returns:
DOCUMENT ME!

### getSample

```public static int[] getSample(int m,
int n,
int t)```
This method computes a sample of a specified size from a population of the form 1, 2, ..., m

Parameters:
`m` - the population size
`n` - the sample size
`t` - the type (0 without replacement, 1 with replacement)
Returns:
DOCUMENT ME!

### sort

`public static double[] sort(double[] a)`
This method sorts an array of doubles. Beware as this method is probably suboptimal.

Parameters:
`a` - the array of doubles
Returns:
the sorted arry

### sort

`public static int[] sort(int[] a)`
This method sorts an array of integers. Beware as this method is probably suboptimal.

Parameters:
`a` - the array of integers
Returns:
the sorted arry

### isReal

`public static boolean isReal(double x)`
This class method tests to see if a specified number is real.

Parameters:
`x` - the number
Returns:
true if the number is real and finite