Class HyperExp

All Implemented Interfaces:
Serializable, Copyable

public class HyperExp extends Markovian implements Serializable
A hyper-exponential distribution.
See Also:
  • Constructor Details

    • HyperExp

      public HyperExp(double p, double lambda1, double lambda2)
    • HyperExp

      public HyperExp(double p, double lambda)
    • HyperExp

      public HyperExp(double[] p, double[] lambda)
      Creates an n-phase hyper-exponential distribution: with probability p[i] the sample is exponential with rate lambda[i].

      This mirrors the MATLAB HyperExp representation exactly: D0 = -diag(lambda), D1 = -D0*p(:)*ones(1,n), i.e. D1(i,j) = lambda(i)*p(j). For n = 2 this coincides with the (p, lambda1, lambda2) constructor.

      Parameters:
      p - branch probabilities, one per phase (must sum to 1)
      lambda - phase rates, one per phase
    • HyperExp

      public HyperExp(Matrix p, Matrix lambda)
      Creates an n-phase hyper-exponential distribution from Matrix vectors.
      Parameters:
      p - branch probabilities, one per phase (must sum to 1)
      lambda - phase rates, one per phase
  • Method Details

    • getP

      public double[] getP()
      Gets the branch probabilities, one per phase.
      Returns:
      a copy of the branch probability vector
    • getLambda

      public double[] getLambda()
      Gets the phase rates, one per phase.
      Returns:
      a copy of the rate vector
    • fit

      public static HyperExp fit(ContinuousDistribution dist, String method)
      Fit a hyperexponential to the ccdf of dist ITSELF at points spread over decades of time scale, rather than to its moments (HyperexpFitLongtail, Feldmann and Whitt 1998).

      That is the only form available for a long-tail law: a Pareto with tail index below 2 has no finite variance, so the moment fits above do not exist at all, and even where the moments are finite they say nothing about the orders of magnitude over which such a law acts.

      Parameters:
      dist - the law to approximate
      method - the fitting method; only "feldmannwhitt" is defined here
      Returns:
      the fitted hyperexponential
    • fitMeanAndSCV

      public static HyperExp fitMeanAndSCV(double mean, double scv)
    • fitMeanAndSCVBalanced

      public static HyperExp fitMeanAndSCVBalanced(double mean, double scv)
      Fit distribution with given squared coefficient of variation and balanced means i.e., p/mu1 = (1-p)/mu2
    • evalCDF

      public double evalCDF(double t)
      Description copied from class: Markovian
      Evaluates the cumulative distribution function at the given point.
      Overrides:
      evalCDF in class Markovian
      Parameters:
      t - the point at which to evaluate the CDF
      Returns:
      the CDF value at point t
    • evalLST

      public double evalLST(double s)
      Description copied from class: Distribution
      Evaluate the Laplace-Stieltjes Transform at s
      Overrides:
      evalLST in class Markovian
      Parameters:
      s - the Laplace domain variable
      Returns:
      the LST value at s
    • getMean

      public double getMean()
      Description copied from class: Markovian
      Gets the mean of this Markovian distribution.
      Overrides:
      getMean in class Markovian
      Returns:
      the mean value, or NaN if the process contains NaN values
    • getNumberOfPhases

      public long getNumberOfPhases()
      Description copied from class: Markovian
      Gets the number of phases in this Markovian distribution.
      Overrides:
      getNumberOfPhases in class Markovian
      Returns:
      the number of phases
    • getRate

      public double getRate()
      Description copied from class: Distribution
      Gets the rate of this distribution (inverse of mean).
      Overrides:
      getRate in class Markovian
      Returns:
      the rate value (1/mean)
    • getSCV

      public double getSCV()
      Description copied from class: Distribution
      Gets the squared coefficient of variation (SCV) of this distribution. SCV = Var(X) / E[X]^2.
      Overrides:
      getSCV in class Markovian
      Returns:
      the squared coefficient of variation
    • getSkewness

      public double getSkewness()
      Description copied from class: Distribution
      Gets the skewness of this distribution. Skewness measures the asymmetry of the probability distribution.
      Overrides:
      getSkewness in class Markovian
      Returns:
      the skewness value
    • getVar

      public double getVar()
      Description copied from class: Distribution
      Gets the variance of this distribution. Computed as SCV * mean^2.
      Overrides:
      getVar in class Markovian
      Returns:
      the variance
    • sample

      public double[] sample(int n)
      Gets n samples from the distribution
      Overrides:
      sample in class Markovian
      Parameters:
      n - - the number of samples
      Returns:
      - n samples from the distribution
    • sample

      public double[] sample(int n, Random random)
      Description copied from class: Distribution
      Generates random samples from this distribution using the specified random generator.
      Overrides:
      sample in class Markovian
      Parameters:
      n - the number of samples to generate
      random - the random number generator to use
      Returns:
      array of random samples
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • mean

      public double mean()
      Property alias for getMean
      Overrides:
      mean in class Markovian
    • rate

      public double rate()
      Property alias for getRate
      Overrides:
      rate in class Markovian
    • scv

      public double scv()
      Property alias for getSCV
      Overrides:
      scv in class Markovian
    • skewness

      public double skewness()
      Property alias for getSkewness
      Overrides:
      skewness in class Markovian
    • var

      public double var()
      Property alias for getVar
      Overrides:
      var in class Markovian
    • numberOfPhases

      public long numberOfPhases()
      Property alias for getNumberOfPhases
      Overrides:
      numberOfPhases in class Markovian
    • numPhases

      public long numPhases()
      Property alias for getNumberOfPhases
      Overrides:
      numPhases in class Markovian