Class Prior

All Implemented Interfaces:
Serializable, Copyable

public class Prior extends Distribution implements Serializable
Prior distribution representing parameter uncertainty over alternative distributions. Prior represents parameter uncertainty by specifying a discrete set of alternative distributions with associated probabilities. When used with setService or setArrival, it causes the Posterior solver to expand the model into a family of networks, one for each alternative. This is NOT a mixture distribution - each alternative represents a separate model realization with its associated prior probability. Example usage:
 List<Distribution> dists = Arrays.asList(new Exp(1.0), new Exp(2.0), new Erlang(1.5, 2));
 double[] probs = {0.4, 0.35, 0.25};
 Prior prior = new Prior(dists, probs);
 queue.setService(jobclass, prior);
 
See Also:
  • Field Details

    • distributions

      protected List<Distribution> distributions
      Cell array of alternative distributions
    • probabilities

      protected double[] probabilities
      Vector of prior probabilities (must sum to 1)
  • Constructor Details

    • Prior

      public Prior(List<Distribution> distributions, double[] probabilities)
      Creates a Prior distribution with specified alternatives and probabilities.
      Parameters:
      distributions - list of alternative Distribution objects
      probabilities - array of probabilities (must sum to 1 and be non-negative)
      Throws:
      RuntimeException - if validation fails
    • Prior

      public Prior(Distribution[] distributions, double[] probabilities)
      Convenience constructor for array-based input.
      Parameters:
      distributions - array of alternative Distribution objects
      probabilities - array of probabilities
  • Method Details

    • getNumAlternatives

      public int getNumAlternatives()
      Returns the number of alternative distributions.
      Returns:
      number of alternatives
    • getAlternative

      public Distribution getAlternative(int idx)
      Returns the distribution at the specified index.
      Parameters:
      idx - 0-based index
      Returns:
      the distribution at index idx
      Throws:
      IndexOutOfBoundsException - if idx is out of bounds
    • getProbability

      public double getProbability(int idx)
      Returns the probability of the alternative at the specified index.
      Parameters:
      idx - 0-based index
      Returns:
      the probability at index idx
      Throws:
      IndexOutOfBoundsException - if idx is out of bounds
    • getProbabilities

      public double[] getProbabilities()
      Returns the array of all probabilities.
      Returns:
      copy of probability array
    • getDistributions

      public List<Distribution> getDistributions()
      Returns the list of all distributions.
      Returns:
      list of distributions (unmodifiable view recommended)
    • getMean

      public double getMean()
      Gets the prior-weighted mean (expected mean over alternatives). E[X] = sum_i p_i * E[X_i]
      Specified by:
      getMean in class Distribution
      Returns:
      the weighted mean
    • getSCV

      public double getSCV()
      Gets the prior-weighted SCV using law of total variance. Var(X) = E[Var(X|D)] + Var(E[X|D]) SCV = Var(X) / E[X]^2
      Specified by:
      getSCV in class Distribution
      Returns:
      the weighted SCV
    • getSkewness

      public double getSkewness()
      Gets the prior-weighted skewness. Uses mixture formula with moment calculations.
      Specified by:
      getSkewness in class Distribution
      Returns:
      the weighted skewness
    • sample

      public double[] sample(int n, Random random)
      Generates random samples from the Prior (mixture sampling). Each sample is drawn from one of the alternatives selected according to the prior probabilities.
      Specified by:
      sample in class Distribution
      Parameters:
      n - number of samples
      random - the random number generator
      Returns:
      array of samples
    • evalCDF

      public double evalCDF(double t)
      Evaluates the mixture CDF at t. F(t) = sum_i p_i * F_i(t)
      Specified by:
      evalCDF in class Distribution
      Parameters:
      t - the point at which to evaluate
      Returns:
      the CDF value
    • evalLST

      public double evalLST(double s)
      Evaluates the mixture Laplace-Stieltjes transform. L(s) = sum_i p_i * L_i(s)
      Specified by:
      evalLST in class Distribution
      Parameters:
      s - the transform variable
      Returns:
      the LST value
    • isPrior

      public boolean isPrior()
      Returns true indicating this is a Prior distribution. Used for detection by Posterior solver.
      Returns:
      true
    • isPriorDistribution

      public static boolean isPriorDistribution(Distribution dist)
      Static method to check if a distribution is a Prior.
      Parameters:
      dist - the distribution to check
      Returns:
      true if dist is a Prior