org.ojalgo.random

## Class RandomUtils

• ```public abstract class RandomUtils
extends Object```
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```calculateVariance(double aSumOfValues, double aSumOfSquaredValues, int aValuesCount)```
`static double` `erf(double anArg)`
`static double` `erfc(double anArg)`
`static double` `erfi(double anArg)`
`static double` `factorial(int aVal)`
`static double` `gamma(double arg)`
Lanczos approximation.
`static int` ```partitions(int n, int[] k)```
`static int` `permutations(int n)`
`static int` ```subsets(int n, int k)```
`static int` ```variations(int n, int k)```
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

• #### calculateVariance

```public static double calculateVariance(double aSumOfValues,
double aSumOfSquaredValues,
int aValuesCount)```
Parameters:
`aSumOfValues` - The sum of all values in a sample set
`aSumOfSquaredValues` - The sum of all squared values, in a sample set
`aValuesCount` - The number of values in the sample set
Returns:
The sample set's variance
• #### factorial

`public static double factorial(int aVal)`
• #### gamma

`public static double gamma(double arg)`
Lanczos approximation. The abritray constant is 7, and there are 9 coefficients used. Essentially the algorithm is taken from WikipediA , but it's modified a bit and I found more exact coefficients somewhere else.
• #### partitions

```public static int partitions(int n,
int[] k)```
Parameters:
`n` - The number of elements in the set
`k` - A vector of subset sizes the sum of which must equal the size of the full set
Returns:
The number of ways the set can be partioned in to subsets of the given sizes
• #### permutations

`public static int permutations(int n)`
Parameters:
`n` - The number of elements in the set
Returns:
The number of permutations of the set
• #### subsets

```public static int subsets(int n,
int k)```
Parameters:
`n` - The number of elements in the set
`k` - The number of elements in the subset
Returns:
The number of subsets to the set
• #### variations

```public static int variations(int n,
int k)```
Parameters:
`n` - The number of elements in the set
`k` - The size of the tuple
Returns:
The number of ordered k-tuples (variations) of the set