Package jline.api.mam

Class Rap_sample

java.lang.Object
jline.api.mam.Rap_sample

public final class Rap_sample extends Object
Rational Arrival Process (RAP) sampling by conditional inversion.

A RAP (H0, H1) generalises a MAP by dropping the sign constraints on the two matrices, so the CTMC walk of Map_sample does not apply. Sampling is instead performed on the conditional (vector) representation: with a row vector v satisfying v*e = 1, the next inter-event time has survival function S_v(x) = v*expm(H0*x)*e and density f_v(x) = -v*expm(H0*x)*H0*e = v*expm(H0*x)*H1*e, and after an event at x the vector is updated to

v <- v*expm(H0*x)*H1 / (v*expm(H0*x)*H1*e)

The generated sequence is therefore correlated: it reproduces the autocorrelation of the process, not merely its ME marginal. Starting v from the embedded stationary vector Map_pie makes each inter-event time marginally stationary. A MAP is the special case in which H0 has non-negative off-diagonal entries and H1 is non-negative; the algorithm is exact there too, although Map_sample.MapSampler is cheaper for that case.

Because v changes at every draw, no inversion table can be cached across draws. What is cached is the sequence expm(H0*t_i) on a fixed time grid (built with a single matrix exponential and repeated matrix products), together with the column vectors expm(H0*t_i)*e. A draw then costs only vector products: the conditional survival at a grid point is a dot product against the cached column, so no matrix exponential is evaluated per draw.

Since:
LINE 3.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Stateful RAP sampler that carries the conditional phase vector across draws, so successive inter-event times are correlated as in the process.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    rap_sample(MatrixCell RAP, long n, Random random)
    Generates a correlated sample sequence from a Rational Arrival Process.
    static double[]
    rap_sample(Matrix H0, Matrix H1, long n, Random random)
    Generates a correlated sample sequence from a Rational Arrival Process given its two matrices.

    Methods inherited from class java.lang.Object

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

    • rap_sample

      public static double[] rap_sample(MatrixCell RAP, long n, Random random)
      Generates a correlated sample sequence from a Rational Arrival Process.

      The returned inter-event times are not i.i.d.: they carry the autocorrelation of the process, obtained by propagating the conditional phase vector across events. A MAP is the special case in which H0 has non-negative off-diagonal entries and H1 is non-negative.

      Parameters:
      RAP - the process as a MatrixCell {H0, H1}
      n - the number of samples to generate
      random - the random number generator to use
      Returns:
      an array of n correlated inter-event times
    • rap_sample

      public static double[] rap_sample(Matrix H0, Matrix H1, long n, Random random)
      Generates a correlated sample sequence from a Rational Arrival Process given its two matrices.
      Parameters:
      H0 - the hidden-transition matrix
      H1 - the visible-transition matrix
      n - the number of samples to generate
      random - the random number generator to use
      Returns:
      an array of n correlated inter-event times