jphase.generator
Class GeneratorUtils

java.lang.Object
  extended by jphase.generator.GeneratorUtils

public class GeneratorUtils
extends java.lang.Object

This class contains a set of methods to make some usual calculations for the PhaseGenerator classes

Author:
Juan Fernando Pérez

Constructor Summary
GeneratorUtils()
           
 
Method Summary
static double algorKS(double[] data, PhaseVar var)
          This method implements the KS algorithm proposed by González, Sahni and Franta in "An efficient algorithm for the Kolmogorov-Smirnov and Lilliefors Tests" in ACM Transactions on Mathematical Software, Vol 3, No.
static void aliasCut(double[] dist, int[] alias, double[] cutoff)
          This method generates the aliases and cutoff values according to the distribution especified.
static void aliasCut(no.uib.cipr.matrix.Vector dist, int[] alias, double[] cutoff)
          This method generates the aliases and cutoff values according to the distribution especified.
static int argmax(double[] data)
          Returns the index of the maximum value in the data
static int argmin(double[] data)
          Returns the index of the minimum value in the data
static double erlang(double lambda, int r, java.util.Random rand)
          Returns a random number with Erlang(lambda, r) distribution.
static int getNumber(double[] dist, int[] alias, double[] cutoff, java.util.Random rand)
          Returns a random number with discrete distribution dist in {0,...,n}
static double sum(double[] data)
          Returns the sum of the elements of the data array
static double sumAbs(double[] data)
          Returns the sum of the absolut values of the elements of the data array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneratorUtils

public GeneratorUtils()
Method Detail

argmin

public static int argmin(double[] data)
Returns the index of the minimum value in the data

Parameters:
data - array of data
Returns:
The index of the minimum value in the data

argmax

public static int argmax(double[] data)
Returns the index of the maximum value in the data

Parameters:
data - array of data
Returns:
The index of the maximum value in data

sum

public static double sum(double[] data)
Returns the sum of the elements of the data array

Parameters:
data - array of data
Returns:
Sum of the elements of the data array

sumAbs

public static double sumAbs(double[] data)
Returns the sum of the absolut values of the elements of the data array

Parameters:
data - array of data
Returns:
Sum of the absolut values of the elements of the data array

aliasCut

public static void aliasCut(no.uib.cipr.matrix.Vector dist,
                            int[] alias,
                            double[] cutoff)
This method generates the aliases and cutoff values according to the distribution especified. This distribution comes in a MTJ Vector and may sum less than one (as in the initial condition vector that defines a Markov process or a Phase-Type distribution). The distribution is then adjusted by adding a position in zero that completes the probability mass to summ to zero.

Parameters:
dist - Distribution from which the aliases and cutoff vectors must be generated. Represented by a MTJ Vector.
alias - vector of the distribution
cutoff - values of the distribution

aliasCut

public static void aliasCut(double[] dist,
                            int[] alias,
                            double[] cutoff)
This method generates the aliases and cutoff values according to the distribution especified.

Parameters:
dist - Distribution from which the aliases and cutoff vectors must be generated. Represented by array of doubles.
alias - vector of the distribution
cutoff - values of the distribution

getNumber

public static int getNumber(double[] dist,
                            int[] alias,
                            double[] cutoff,
                            java.util.Random rand)
Returns a random number with discrete distribution dist in {0,...,n}

Parameters:
dist - Discrete distribution in {0,...,n}
alias - Aliases of the distributions points
cutoff - Cutoff values to generate the random numbers
rand - Random type object to use as generator of random numbers
Returns:
A random number with discrete distribution dist in {0,...,n}

erlang

public static double erlang(double lambda,
                            int r,
                            java.util.Random rand)
Returns a random number with Erlang(lambda, r) distribution.

Parameters:
lambda - Erlang rate
r - number of phases in the Erlang Distribution
rand - Random number source
Returns:
random number with Erlang(lambda, r) distribution.

algorKS

public static double algorKS(double[] data,
                             PhaseVar var)
This method implements the KS algorithm proposed by González, Sahni and Franta in "An efficient algorithm for the Kolmogorov-Smirnov and Lilliefors Tests" in ACM Transactions on Mathematical Software, Vol 3, No. 1, March 1977, pages 60-64.

Parameters:
data - data trace to be tested
var - theoretical phase variable to be compared against the trace
Returns:
absolute maximum deviation from the data to the phase variable