Package jline.api.mam

Class Me_sample

java.lang.Object
jline.api.mam.Me_sample

public final class Me_sample extends Object
Matrix Exponential (ME) sampling by numerical inversion of the exact CDF.

An ME distribution with representation (alpha, A) has F(t) = 1 - alpha*expm(A*t)*e and density f(t) = -alpha*expm(A*t)*A*e. Unlike a phase-type distribution, alpha may contain negative entries and A may have negative off-diagonal entries, so the CTMC walk used by Map_sample is not applicable: the walk assumes a probabilistic interpretation of the (alpha, A) pair and silently produces garbage when that interpretation does not hold. Inversion of F is valid for every ME representation.

The inversion table is built once per Me_sample.MeSampler instance: a single matrix exponential expm(A*h) generates the whole grid by repeated vector-matrix products, the grid is extended until the survival function is below 1.0E-12, and quantiles above the last tabulated CDF value are obtained by exponential extrapolation with the dominant eigenvalue of A rather than being clamped to the grid endpoint. Each quantile is refined by Newton steps on the exact CDF/density, so the result is near-exact rather than piecewise linear.

Since:
LINE 3.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Stateful ME sampler that builds the inverse-CDF table once and draws independent variates from it.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Matrix
    Recovers the initial vector alpha of an ME process stored as a MatrixCell {D0 = A, D1 = -A*e*alpha}.
    static double[]
    me_sample(MatrixCell ME, long n, Random random)
    Generates random samples from an ME distribution stored in a MatrixCell {D0 = A, D1 = -A*e*alpha}.
    static double[]
    me_sample(Matrix alpha, Matrix A, long n, Random random)
    Generates random samples from a Matrix Exponential (ME) distribution by numerical inversion of its exact cumulative distribution function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • me_sample

      public static double[] me_sample(Matrix alpha, Matrix A, long n, Random random)
      Generates random samples from a Matrix Exponential (ME) distribution by numerical inversion of its exact cumulative distribution function.
      Parameters:
      alpha - the initial vector of the ME representation
      A - the matrix parameter of the ME representation
      n - the number of samples to generate
      random - the random number generator to use
      Returns:
      an array of n i.i.d. samples
    • me_sample

      public static double[] me_sample(MatrixCell ME, long n, Random random)
      Generates random samples from an ME distribution stored in a MatrixCell {D0 = A, D1 = -A*e*alpha}.

      D1 of an ME process is the rank-one matrix (-A*e)*alpha, so alpha is recovered as the row of D1 with the largest |(-A*e)| entry, divided by that entry. If the recovered alpha does not reproduce D1 the pair is a general Rational Arrival Process rather than an ME renewal process, and sampling is delegated to Rap_sample.

      Parameters:
      ME - the process as a MatrixCell {D0, D1}
      n - the number of samples to generate
      random - the random number generator to use
      Returns:
      an array of n samples
    • me_alpha

      public static Matrix me_alpha(MatrixCell ME)
      Recovers the initial vector alpha of an ME process stored as a MatrixCell {D0 = A, D1 = -A*e*alpha}.

      D1 is rank one for an ME renewal process, so alpha is read off the row with the largest |(-A*e)| entry and validated by reconstructing the whole of D1. A null return means the pair is not an ME renewal process (the caller must then treat it as a general RAP).

      Parameters:
      ME - the process as a MatrixCell {D0, D1}
      Returns:
      the recovered alpha as a 1 x n row vector, or null if D1 is not the rank-one matrix implied by an ME representation