Class Distribution

java.lang.Object
common.distributions.Distribution
All Implemented Interfaces:
ServiceStrategy, Cloneable
Direct Known Subclasses:
Batch, Bernoulli, Binomial, Burst, Coxian, Deterministic, DiscreteUniform, Erlang, Exponential, Gamma, Hyperexponential, Lognormal, MAP, MMPP2, Normal, Pareto, PhaseType, Poisson, Poisson, Replayer, ShiftedGeometric, StudentT, Uniform, Weibull, Zipf

public abstract class Distribution extends Object implements ServiceStrategy

Title: Distribution

Description: This abstract class provides a generic pattern used to specify a distribution.

Author:
Bertoli Marco Date: 25-giu-2005 Time: 14.47.12
  • Field Details

    • all

      protected static Distribution[] all
    • allWithMean

      protected static Distribution[] allWithMean
    • nestableDistributions

      protected static Distribution[] nestableDistributions
    • discreteDistributions

      protected static Distribution[] discreteDistributions
    • df

      protected static DecimalFormat df
    • classpath

      protected String classpath
    • name

      protected String name
    • parameterClasspath

      protected String parameterClasspath
    • parameters

      protected Distribution.Parameter[] parameters
    • description

      protected String description
    • image

      protected ImageIcon image
    • checker

      protected Distribution.ValueChecker checker
    • precondition

      protected String precondition
    • hasMean

      protected boolean hasMean
    • hasC

      protected boolean hasC
    • mean

      protected double mean
    • c

      protected double c
    • isNestable

      protected boolean isNestable
  • Constructor Details

    • Distribution

      public Distribution(String name, String classpath, String parameterClasspath, String description)
      Constructs a new Distribution object. Initialize all internal objects calling abstract methods setParameterNames(), setParameterClasses(), setParameterValues().
      Parameters:
      name - Name of the distribution
      classpath - engine's classpath for this distribution
      parameterClasspath - engine's classpath for this distribution's parameters
      description - description of this distribution
  • Method Details

    • getClassPath

      public String getClassPath()
      Gets engine's classpath for this distribution
      Returns:
      classpath
    • getParameterClassPath

      public String getParameterClassPath()
      Gets engine's classpath for this distribution's parameters (This is needed as each distribution in the engine has a Distribution object and a Parameter object which are distinct classes)
      Returns:
      parameter's classpath
    • getName

      public String getName()
      Gets this distribution's name
      Returns:
      distribution's name
    • getDescription

      public String getDescription()
      Gets this distribution description
      Returns:
      distribution's description
    • getNumberOfParameters

      public int getNumberOfParameters()
      Returns number of parameters for this distribution
      Returns:
      number of parameters
    • getParameter

      public Distribution.Parameter getParameter(int num)
      Gets a parameter data structure of this distribution, given its index
      Parameters:
      num - index of requested parameter
      Returns:
      requested parameter
      Throws:
      ArrayIndexOutOfBoundsException - if num is not inside bounds
    • getParameter

      public Distribution.Parameter getParameter(String name)
      Gets a parameter data structure of this distribution, given its name
      Parameters:
      name - name of parameter to be retrieved
      Returns:
      requested parameter or null if a parameter with specified name does not exist
    • getImage

      public ImageIcon getImage()
      Gets explicative image of this distribution used, together with description, to help the user to understand meaning of parameters.
      Returns:
      explicative image
    • checkValue

      public boolean checkValue()
      Checks if all parameters' values are correct for this distribution type
      Returns:
      true if no check has to be performed or parameters are correct, false otherwise.
    • getPrecondition

      public String getPrecondition()
      Returns precondition that parameters' values must satisfy for this distribution to be valid Every Distribution that provides a checker must provide a valid precondition message too.
      Returns:
      Message describing distribution's preconditions
    • clone

      public Distribution clone()
      Returns a deep copy of this Distribution
      Specified by:
      clone in interface ServiceStrategy
      Overrides:
      clone in class Object
      Returns:
      a clone of this distribution
    • hasMean

      public boolean hasMean()
      Returns if this distribution can be initialized providing its mean value
      Returns:
      true iff this distribution can be initialized using its mean value
    • hasC

      public boolean hasC()
      Returns if this distribution can be initialized providing variation coefficient C
      Returns:
      true iff this distribution can be initialized using variation coefficient C
    • getMean

      public double getMean()
      Returns distribution mean only if hasMean() is true
      Returns:
      distribution Mean
    • getC

      public double getC()
      Returns distribution variation coefficient C only if hasC() is true
      Returns:
      variation coefficient C
    • setValueChecker

      protected void setValueChecker(Distribution.ValueChecker checker)
      Sets a value checker for this entire distribution (checks intra-parameters preconditions)
      Parameters:
      checker - checker to be set to this distribution
    • isNestable

      public boolean isNestable()
      Returns whether a distribution can be used as nested distribution inside another distribution
      Returns:
      true if it can be nested. false otherwise
    • formatNumber

      public String formatNumber(double d)
      Helper method used to format given number into string according to default rules.
      Parameters:
      d - double to be converted
      Returns:
      string representation of given number
    • findAll

      public static Distribution[] findAll()
      Returns an array with an instance of every allowed Distribution. Uses internal caching to search for distributions only the first time that this method is called. Note: this method is used to get all continuous distributions. If you need discrete distributions, use findAllDiscrete().
      Returns:
      an array with an instance of every allowed Distribution
    • findAllWithMean

      public static Distribution[] findAllWithMean()
      Returns an array with an instance of every Distribution that allows mean setting. Uses internal caching to search for distributions only the first time that this method is called.
      Returns:
      an array with an instance of every Distribution in which mean value can be specified
    • findNestableDistributions

      public static Distribution[] findNestableDistributions()
      Returns an array with an instance of every nestable Distribution. Uses internal caching to search for distributions only the first time that this method is called.
      Returns:
      an array with an instance of every nestable Distribution
    • findAllDiscrete

      public static Distribution[] findAllDiscrete()
      Returns an array with an instance of every discrete Distribution. Uses internal caching to search for distributions only the first time that this method is called.
      Returns:
      an array with an instance of every discrete Distribution
    • checkProbabilityVector

      public boolean checkProbabilityVector(Object[][] v)
      Checks if the entries of an probability vector sum up to one.
      Parameters:
      v - vector to be checked
      Returns:
      true if the vector satisfies the condition, false otherwise
    • normalizeProbabilityVector

      public void normalizeProbabilityVector(Object[][] v)
      Normalizes the entries of a probability vector to sum up to one.
      Parameters:
      v - vector to be normalized
    • checkTransitionRateMatrix

      public boolean checkTransitionRateMatrix(Object[][] m)
      Checks if the diagonal of a transition rate matrix only contains negative entries and if the entries in each row of the matrix sum up to a non-positive value.
      Parameters:
      m - matrix to be checked
      Returns:
      true if the matrix satisfies the condition, false otherwise
    • checkInfinitesimalGeneratorMatrix

      public boolean checkInfinitesimalGeneratorMatrix(Object[][] m0, Object[][] m1)
      Checks if the entries in each row of an infinitesimal generator matrix sum up to zero.
      Parameters:
      m0 - hidden matrix to be checked
      m1 - observable matrix to be checked
      Returns:
      true if the matrix satisfies the condition, false otherwise
    • equals

      public boolean equals(Object o)
      Tells if this distribution is equivalent to another one.
      Overrides:
      equals in class Object
      Parameters:
      o - other distribution
      Returns:
      true if equals, false otherwise
    • setParameters

      protected abstract Distribution.Parameter[] setParameters()
      Used to set parameters of this distribution
      Returns:
      distribution parameters
    • setImage

      protected abstract ImageIcon setImage()
      Sets explicative image of this distribution used, together with description, to help the user to understand meaning of parameters
      Returns:
      explicative image
    • toString

      public abstract String toString()
      Returns this distribution's short description
      Overrides:
      toString in class Object
      Returns:
      distribution's short description
    • setMean

      public void setMean(double value)
      Sets the mean for this distribution
      Parameters:
      value - mean value
    • setC

      public void setC(double value)
      Sets the variation coefficient C for this distribution
      Parameters:
      value - variation coefficient C value
    • updateCM

      public void updateCM()
      This method has to be called whenever a parameter changes and hasMean or hasC is true