jphase.generator

## Class GeneratorUtils

- java.lang.Object
- - jphase.generator.GeneratorUtils

-     public class GeneratorUtils
      extends java.lang.Object

  This class contains a set of methods with common computations for the PhaseGenerator classes
  Version:
    1.0
  Author:
    Juan F. Pérez

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeneratorUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `static void` | `aliasCut(double[] dist, int[] alias, double[] cutoff)` This method generates the aliases and cutoff values according to the distribution specified.
    `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 specified.
    `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,...
    `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 absolute values of the elements of the data array

    - ### Methods inherited from class java.lang.Object

      `equals, 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 absolute values of the elements of the data array
      Parameters:
        `data` - array of data
      Returns:
        Sum of the absolute 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 specified. This distribution is an MTJ Vector and may sum less than one (as in the initial probability vector of a Phase-type distribution). The distribution is then adjusted by adding a position in zero that completes the probability mass to sum to zero.
      Parameters:
        `dist` - Distribution from which the aliases and cutoff vectors must be generated. Represented by an 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 specified.
      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