| Package | com.masterbaboon |
| Class | public class AdvancedMath |
| Inheritance | AdvancedMath Object |
| Method | Defined By | ||
|---|---|---|---|
add(x:Array, y:Array):Array [static]
Add two arrays elementwise. | AdvancedMath | ||
factorial(x:int):Number [static]
Computes the factorial of x. | AdvancedMath | ||
gamma(x:Number):Number [static]
Lanczos implementation of the Gamma function,
cf. | AdvancedMath | ||
lnGamma(x:Number):Number [static]
Lanczos implementation of the log Gamma function,
cf. | AdvancedMath | ||
mean(x:Array):Number [static]
Compute the mean of the input array x. | AdvancedMath | ||
sampleDirichlet(alpha:Array):Array [static]
Sample from a Dirichlet distribution. | AdvancedMath | ||
sampleGamma(k:Number, theta:Number):Number [static]
Sample from a Gamma(k, theta) distribution. | AdvancedMath | ||
sampleMultinomial(p:Array):int [static]
Sample from a multinomial distribution. | AdvancedMath | ||
sum(x:Array):Number [static]
Compute the sum of the elements of the input array x
| AdvancedMath | ||
variance(x:Array):Number [static]
Compute the variance of the input array x. | AdvancedMath | ||
zeros(dim:int, val:Number = 0):Array [static]
Create a new array with elements initialized to a particular value. | AdvancedMath | ||
| Constant | Defined By | ||
|---|---|---|---|
| FACTORIAL_MAXEXACT : Number = 20 [static] | AdvancedMath | ||
| add | () | method |
public static function add(x:Array, y:Array):ArrayAdd two arrays elementwise. They must be of the same length.
Parameters
x:Array | |
y:Array |
Array |
| factorial | () | method |
public static function factorial(x:int):NumberComputes the factorial of x. Requested values are cached to speed-up future calls. If x>FACTORIAL_MAXEXACT, the result is approximated using the Gamma function, as x! = Gamma(x+1) .
Parameters
x:int |
Number |
| gamma | () | method |
public static function gamma(x:Number):NumberLanczos implementation of the Gamma function, cf. Numerical Recipes in C (2nd edition, p.213). Reference: Lanczos, C. 1964, SIAM Journal on Numerical Analysis, ser. B, vol. 1, pp. 86–96.
Parameters
x:Number |
Number |
| lnGamma | () | method |
public static function lnGamma(x:Number):NumberLanczos implementation of the log Gamma function, cf. Numerical Recipes in C (2nd edition, p.213). Reference: Lanczos, C. 1964, SIAM Journal on Numerical Analysis, ser. B, vol. 1, pp. 86–96.
Parameters
x:Number |
Number |
| mean | () | method |
public static function mean(x:Array):NumberCompute the mean of the input array x.
Parameters
x:Array |
Number |
| sampleDirichlet | () | method |
public static function sampleDirichlet(alpha:Array):ArraySample from a Dirichlet distribution. Dirichlet distribution can be used as prior for multinomial variables.
Parameters
alpha:Array — Array of parameters for the Dirichlet distribution
|
Array |
See also
| sampleGamma | () | method |
public static function sampleGamma(k:Number, theta:Number):NumberSample from a Gamma(k, theta) distribution. The definition and the sample generating algorithm are as at http://en.wikipedia.org/wiki/Gamma_distribution . For the Matlab Gamma(alpha, beta) definition, call Gamma(alpha, 1/beta).
Parameters
k:Number | |
theta:Number |
Number |
| sampleMultinomial | () | method |
public static function sampleMultinomial(p:Array):intSample from a multinomial distribution. In other words, choose randomly from a set of N choices with probabilities p[0], ..., p[N-1]
Parameters
p:Array — An array of probabilities, one for each element.
p must sum to 1.
|
int |
| sum | () | method |
public static function sum(x:Array):NumberCompute the sum of the elements of the input array x
Parameters
x:Array |
Number |
| variance | () | method |
public static function variance(x:Array):NumberCompute the variance of the input array x.
Parameters
x:Array |
Number |
| zeros | () | method |
public static function zeros(dim:int, val:Number = 0):ArrayCreate a new array with elements initialized to a particular value.
Parameters
dim:int — Number of dimensions
| |
val:Number (default = 0) — Value to initialize the array to. Default: 0
|
Array |
| FACTORIAL_MAXEXACT | Constant |
public static const FACTORIAL_MAXEXACT:Number = 20