Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.math
Class MathUtil

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.math.MathUtil

public class MathUtil
extends Object

A collection of math related utility functions.


Constructor Summary
MathUtil()
           
 
Method Summary
static double binomialCoefficient(int n, int k)
           Binomial coefficent, also known as "n choose k")
static double factorial(int n)
          Compute the Factorial of n, often written as c!
static double hypotenuse(double a, double b)
          Computes the square root of the sum of the squared arguments without under or overflow.
static double mahalanobisDistance(Matrix weightMatrix, Vector o1_minus_o2)
          Compute the Mahalanobis distance using the given weight matrix
static double normalCDF(double x, double mu, double sigma)
          Cumulative probability density function (CDF) of a normal distribution.
static double normalPDF(double x, double mu, double sigma)
          Probability density function of the normal distribution.
static
<V extends NumberVector<V,N>,N extends Number>
double
pearsonCorrelationCoefficient(NumberVector<V,?> x, NumberVector<V,?> y)
           Provides the Pearson product-moment correlation coefficient for two FeatureVectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtil

public MathUtil()
Method Detail

hypotenuse

public static double hypotenuse(double a,
                                double b)
Computes the square root of the sum of the squared arguments without under or overflow.

Parameters:
a - first cathetus
b - second cathetus
Returns:
sqrt(a<sup>2</sup> + b<sup>2</sup>)

mahalanobisDistance

public static double mahalanobisDistance(Matrix weightMatrix,
                                         Vector o1_minus_o2)
Compute the Mahalanobis distance using the given weight matrix

Parameters:
weightMatrix - Weight Matrix
o1_minus_o2 - Delta vector
Returns:
Mahalanobis distance

pearsonCorrelationCoefficient

public static <V extends NumberVector<V,N>,N extends Number> double pearsonCorrelationCoefficient(NumberVector<V,?> x,
                                                                                                  NumberVector<V,?> y)

Provides the Pearson product-moment correlation coefficient for two FeatureVectors.

Type Parameters:
V - type of the FeatureVectors
N - type of the numerical attributes of the FeatureVectors of type V
Parameters:
x - first FeatureVector
y - second FeatureVector
Returns:
the Pearson product-moment correlation coefficient for x and y

factorial

public static double factorial(int n)
Compute the Factorial of n, often written as c! in mathematics.

Parameters:
n - Note: n >= 0
Returns:
n * (n-1) * (n-2) * ... * 1

binomialCoefficient

public static double binomialCoefficient(int n,
                                         int k)

Binomial coefficent, also known as "n choose k")

Parameters:
n - Total number of samples. n > 0
k - Number of elements to choose. n >= k, k >= 0
Returns:
n! / (k! * (n-k)!)

normalPDF

public static double normalPDF(double x,
                               double mu,
                               double sigma)
Probability density function of the normal distribution.
 1/(SQRT(2*pi*sigma^2)) * e^(-(x-mu)^2/2sigma^2)
 

Parameters:
x - The value.
mu - The mean.
sigma - The standard deviation.
Returns:
PDF of the given normal distribution at x.

normalCDF

public static double normalCDF(double x,
                               double mu,
                               double sigma)
Cumulative probability density function (CDF) of a normal distribution.

Parameters:
x - value to evaluate CDF at
mu - Mean value
sigma - Standard deviation.
Returns:
The CDF of the normal given distribution at x.

Release 0.3 (2010-03-31_1612)