de.jstacs.utils
Class Normalisation

java.lang.Object
  extended by de.jstacs.utils.Normalisation

public class Normalisation
extends Object

This class can be used for normalisation of any double array or a part of a double array.

Author:
Jens Keilwagen

Constructor Summary
Normalisation()
           
 
Method Summary
static double getLogSum(double... lnVal)
          Returns the logarithm of the sum of values given as lnVal[i] = Math.log( val[i] ).
static double getLogSum(int start, int end, double... lnVal)
          Returns the logarithm of the sum of values given as lnVal[i] = Math.log( val[i] ) between a start and end index.
static double logSumNormalisation(double[] d)
          The method does a log-sum-normalisation on d with the values of d given as d[i] = Math.log( val[i] ).
static double logSumNormalisation(double[] d, double offset)
          The method does a log-sum-normalisation on d with the values of d given as d[i] = Math.log( val[i] ) using offset offset.
static double logSumNormalisation(double[] d, int startD, int endD)
          The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ).
static double logSumNormalisation(double[] d, int startD, int endD, double[] secondValues)
          The method does a log-sum-normalisation on d within start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ).
static double logSumNormalisation(double[] d, int startD, int endD, double[] secondValues, double[] dest, int startDest)
          The method does a log-sum-normalisation on d within start index startD and end index endD with the values of d given logarithmised: d[i] = Math.log( val[i] ).
static double logSumNormalisation(double[] d, int startD, int endD, double[] dest, int startDest)
          The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ).
static double logSumNormalisation(double[] d, int startD, int endD, double offset, double[] secondValues, double[] dest, int startDest)
          The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ) using offset offset.
static double logSumNormalisation(double[] d, int startD, int endD, double offset, double[] dest, int startDest)
          The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ) using offset offset.
static void normalisation(double[] d, double v)
          The method does a normalisation on d using the value v for normalisation.
static void normalisation(double[] d, double v, double[] dest, int start)
          The method does a normalisation on d writing the result in dest starting at position start while d remains unchanged.
static void normalisation(double[] d, double v, int start, int end)
          The method does a sum normalisation on d between start index start and end index end using the value v for the normalisation.
static double sumNormalisation(double[] d)
          The method does a sum-normalisation on d and returns the the sum of the values.
static double sumNormalisation(double[] d, double[] dest, int start)
          The method does a sum-normalisation on d.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Normalisation

public Normalisation()
Method Detail

getLogSum

public static double getLogSum(double... lnVal)
Returns the logarithm of the sum of values given as lnVal[i] = Math.log( val[i] ).

Parameters:
lnVal - the logs of the values, i.e. lnVal[i] = Math.log( val[i] )
Returns:
the logarithm of the sum of values \log(\sum_i val[i])
See Also:
getLogSum(int, int, double...)

getLogSum

public static double getLogSum(int start,
                               int end,
                               double... lnVal)
Returns the logarithm of the sum of values given as lnVal[i] = Math.log( val[i] ) between a start and end index.

Parameters:
start - the first index in lnVal considered for the sum
end - the index after the last index considered for the sum
lnVal - the logs of the values, i.e. lnVal[i] = Math.log( val[i] )
Returns:
the logarithm of the sum of values between the start and end index \log(\sum_{i=start}^{end - 1} val[i])

logSumNormalisation

public static double logSumNormalisation(double[] d)
The method does a log-sum-normalisation on d with the values of d given as d[i] = Math.log( val[i] ).

Parameters:
d - the array with the logarithmised values that should be normalised
Returns:
the logarithm of the sum of the values \log(\sum_{i=0}^{length(d)-1} val[i])
See Also:
logSumNormalisation(double[], int, int, double[], int)

logSumNormalisation

public static double logSumNormalisation(double[] d,
                                         int startD,
                                         int endD)
The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ).

Parameters:
d - the array with the logarithms of the values that should be normalised
startD - the first index in d considered for the log-sum-normalisation
endD - the index after the last index in d considered for the log-sum-normalisation
Returns:
the logarithm of the sum of the values between startD and endD \log(\sum_{i=startD}^{endD-1} val[i])
See Also:
logSumNormalisation(double[], int, int, double[], int)

logSumNormalisation

public static double logSumNormalisation(double[] d,
                                         int startD,
                                         int endD,
                                         double[] secondValues)
The method does a log-sum-normalisation on d within start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ).
A second array secondValues with additional values secondValues[i] = Math.log( secval[i] ) is also considered for the log-sum-normalisation.

Parameters:
d - the array with the logarithmised values that should be normalised
startD - the first index in d considered for the log-sum-normalisation
endD - the index after the last index in d considered for the log-sum-normalisation
secondValues - second array with additional values, the whole array is considered for the log-sum-normalisation
Returns:
the logarithm of the sum of the values between startD and endD and the values of secondValues
\log(\sum_{i=startD}^{endD-1} val[i] + \sum_{i=0}^{length(secondValues)-1} secval[i])
See Also:
logSumNormalisation(double[], int, int, double, double[], int)

logSumNormalisation

public static double logSumNormalisation(double[] d,
                                         int startD,
                                         int endD,
                                         double[] dest,
                                         int startDest)
The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ).
The method writes the result of d in dest starting at position startDest while d remains unchanged.

Parameters:
d - the array with the logarithmised values that should be normalised
startD - the first index in d considered for the log-sum-normalisation
endD - the index after the last index in d considered for the log-sum-normalisation
dest - the destination array for the normalised values
startDest - the start index of the destination array
Returns:
the logarithm of the sum of the values between startD and endD \log(\sum_{i=startD}^{endD-1} val[i])
See Also:
logSumNormalisation(double[], int, int, double[], double[], int)

logSumNormalisation

public static double logSumNormalisation(double[] d,
                                         int startD,
                                         int endD,
                                         double[] secondValues,
                                         double[] dest,
                                         int startDest)
The method does a log-sum-normalisation on d within start index startD and end index endD with the values of d given logarithmised: d[i] = Math.log( val[i] ).
A second array secondValues with additional values secondValues[i] = Math.log( secval[i] ) is also considered for the log-sum-normalisation.
The method writes the result of d in dest starting at position startDest while d remains unchanged. secondValues will be changed during log-sum-normalisation and will not be written to dest.

Parameters:
d - the array with the logarithmised values that should be normalised
startD - the first index in d considered for the log-sum-normalisation
endD - the index after the last index in d considered for the log-sum-normalisation
secondValues - second array with additional values, the whole array is considered for the log-sum-normalisation
dest - the destination array for the normalised values
startDest - the start index of the destination array
Returns:
the logarithm of the sum of the values of d between startD and endD and the values of secondValue
\log(\sum_{i=startD}^{endD-1} val[i] + \sum_{i=0}^{length(secondValues)-1} secval[i])
See Also:
logSumNormalisation(double[], int, int, double, double[], double[], int)

logSumNormalisation

public static double logSumNormalisation(double[] d,
                                         double offset)
The method does a log-sum-normalisation on d with the values of d given as d[i] = Math.log( val[i] ) using offset offset.
The method returns the logarithm of the sum of the non-logarithmised values.

Parameters:
d - the array with the logarithmised values that should be normalised
offset - the offset
Returns:
the logarithm of the sum of the values \log(\sum_{i=0}^{length(d)-1} val[i])
See Also:
logSumNormalisation(double[], int, int, double, double[], int)

logSumNormalisation

public static double logSumNormalisation(double[] d,
                                         int startD,
                                         int endD,
                                         double offset,
                                         double[] dest,
                                         int startDest)
The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ) using offset offset.
The method writes the result of d in dest starting at position startDest while d remains unchanged.

Parameters:
d - the array with the logarithmised values that should be normalised
startD - the first index in d considered for the log-sum-normalisation
endD - the index after the last index in d considered for the log-sum-normalisation
offset - the offset
dest - the destination array for the normalised values
startDest - the start index of the destination array
Returns:
the logarithm of the sum of the values between startD and endD \log(\sum_{i=startD}^{endD-1} val[i])
See Also:
logSumNormalisation(double[], int, int, double, double[], double[], int)

logSumNormalisation

public static double logSumNormalisation(double[] d,
                                         int startD,
                                         int endD,
                                         double offset,
                                         double[] secondValues,
                                         double[] dest,
                                         int startDest)
The method does a log-sum-normalisation on d between start index startD and end index endD with the values of d given as d[i] = Math.log( val[i] ) using offset offset.
A second array secondValues with additional values secondValues[i] = Math.log( secval[i] ) is also considered for the log-sum-normalisation.
The method writes the result of d in dest starting at position startDest while d remains unchanged. secondValues will be changed during log-sum-normalisation and will not be written to dest.

Parameters:
d - the array with the logarithmised values that should be normalised
startD - the first index in d considered for the log-sum-normalisation
endD - the index after the last index in d considered for the log-sum-normalisation
offset - the offset
secondValues - second array with additional values, the whole array is considered for the log-sum-normalisation
dest - the destination array for the normalised values
startDest - the start index of the destination array
Returns:
the logarithm of the sum of the values of d between startD and endD and the values of secondValue
\log(\sum_{i=startD}^{endD-1} val[i] + \sum_{i=0}^{length(secondValues)-1} secval[i])

sumNormalisation

public static double sumNormalisation(double[] d)
The method does a sum-normalisation on d and returns the the sum of the values.

Parameters:
d - the array with the values that should be normalised
Returns:
the sum of the values of d \sum_{i=0}^{length(d)-1} d[i]
See Also:
sumNormalisation(double[], double[], int)

sumNormalisation

public static double sumNormalisation(double[] d,
                                      double[] dest,
                                      int start)
The method does a sum-normalisation on d.
and writes the result in dest starting at position start while d remains unchanged. The sum of the values of d will be returned.

Parameters:
d - the array with the values that should be normalised
dest - the destination array for the normalised values
start - the start index of the destination array
Returns:
the sum of the values of d \sum_{i=0}^{length(d)-1} d[i]

normalisation

public static void normalisation(double[] d,
                                 double v)
The method does a normalisation on d using the value v for normalisation.

Parameters:
d - the array with the values that should be normalised
v - the value for the normalisation
See Also:
normalisation(double[], double, double[], int)

normalisation

public static void normalisation(double[] d,
                                 double v,
                                 double[] dest,
                                 int start)
The method does a normalisation on d writing the result in dest starting at position start while d remains unchanged. The value v is used for the normalisation.

Parameters:
d - the array with the values that should be normalised
v - the value for normalisation
dest - the destination array for the normalised values
start - the start index of the destination array

normalisation

public static void normalisation(double[] d,
                                 double v,
                                 int start,
                                 int end)
The method does a sum normalisation on d between start index start and end index end using the value v for the normalisation.

Parameters:
d - the array with the values that should be normalised
v - the value for normalisation
start - the first index in d considered for the log-sum-normalisation
end - the index after the last index in d considered for the log-sum-normalisation