net.sourceforge.cilib.math
Class Maths

java.lang.Object
  extended by net.sourceforge.cilib.math.Maths

public final class Maths
extends Object

This class provides helper functions in addtion to the standard java.lang.Math class. These utility functions further are necessary for the various distributions and selections required within CIlib as a whole.

Author:
Gary Pampara

Field Summary
static double EPSILON
           
 
Method Summary
static double choose(double n, double r)
          This is a convienience method providing an alias to combination.
static double combination(double n, double r)
          Return the combination of n and r.
static double factorial(double x)
          Generate the required factorial of the number x.
static int flip(double probability)
          Determine if a "flip" would occur given the provided probability value.
static double log(double base, double value)
          Determine the log of the specified value with the provided base.
static double permutation(double n, double r)
          In combinatorics, a permutation is usually understood to be a sequence containing each element from a finite set once, and only once.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPSILON

public static double EPSILON
Method Detail

factorial

public static double factorial(double x)
Generate the required factorial of the number x.

Parameters:
x - The number to generate the factorial from.
Returns:
The factorial of x.

combination

public static double combination(double n,
                                 double r)
Return the combination of n and r.

Parameters:
n - The total elements from which the combination is perfromed.
r - The r-combinations (of size r) to select.
Returns:
The combination of n and r.

choose

public static double choose(double n,
                            double r)
This is a convienience method providing an alias to combination.

Parameters:
n - The number of elements available for selection.
r - The r-combinations (of size r) to select.
Returns:
The value of the operation "n choose x".

permutation

public static double permutation(double n,
                                 double r)
In combinatorics, a permutation is usually understood to be a sequence containing each element from a finite set once, and only once.

Parameters:
n - The number of elements available for selection.
r - The number of elements to be selected (0 <= r <= n).
Returns:
The number of permutations.

flip

public static int flip(double probability)
Determine if a "flip" would occur given the provided probability value.

Parameters:
probability - The provided probability value. This value must be in [0,1]
Returns:
1 - if a "flip" occured, 0 otherwise.

log

public static double log(double base,
                         double value)
Determine the log of the specified value with the provided base.

Parameters:
base - The base of the log operation.
value - The value to determine the log of.
Returns:
The log value of value using the base value of base.
See Also:
Math.log(double).


Copyright © 2009 CIRG. All Rights Reserved.