Class EmpiricalPar

All Implemented Interfaces:
AutoCheck, Parameter

public class EmpiricalPar extends AbstractParameter implements Parameter
This is the parameter that should be passed to the empirical distribution.

Copyright (c) 2003
Politecnico di Milano - dipartimento di Elettronica e Informazione
Author:
Fabrizio Frontera - ffrontera@yahoo.it
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double[]
    cumulative distribution function
    protected double[]
    probability distribution function
    protected Object[]
    values of the parameter
  • Constructor Summary

    Constructors
    Constructor
    Description
    This is the default constructor.
    EmpiricalPar(double[] pdf)
    It creates a new empirical parameter.
    It creates a new empirical parameter.
    Creates an empirical parameter with these entries (each entry contains a value and a probability).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    It controls if the parameter is correct or not.
    double[]
    It returns the value of the parameters for the empirical distribution, that is the vector of double representing the cumulative distribution function tabulated.
    double[]
    It returns the value of the parameters for the empirical distribution, that is the vector of double representing the probabilities provided by the user.
    getValue(int position)
    Returns the value in the corresponding position: generally only the empirical distribution needs to access this method (generates the random number then ask for the corresponding value).
    Returns all the values.
    static boolean
    guiCheck(String parameterName, Double value)
    Checks whether a parameter value is correct.
    static String
    guiGetErrorMsg(String parameterName)
     
    void
    setPDF(double[] pdf)
    It allows the user to change the value of the parameter of the empirical distribution.

    Methods inherited from class AbstractParameter

    setMean

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Parameter

    setMean
  • Field Details

    • cdf

      protected double[] cdf
      cumulative distribution function
    • pdf

      protected double[] pdf
      probability distribution function
    • values

      protected Object[] values
      values of the parameter
  • Constructor Details

    • EmpiricalPar

      public EmpiricalPar()
      This is the default constructor. It creates a new empty empirical parameter that must be set with the setPDF method before being used.
    • EmpiricalPar

      public EmpiricalPar(double[] pdf) throws IncorrectDistributionParameterException
      It creates a new empirical parameter. It accepts an array of double greater or equal to zero and verifies that the sum of all these data is one or zero.
      Parameters:
      pdf - array of double for the new empirical distribution.
      Throws:
      IncorrectDistributionParameterException - when any of the provided data is less than zero or the sum of all of them is not one or zero.
    • EmpiricalPar

      public EmpiricalPar(Double[] wpdf) throws IncorrectDistributionParameterException
      It creates a new empirical parameter. It accepts an array of Double greater or equal to zero and verifies that the sum of all these data is one or zero.
      Parameters:
      wpdf - array of Double for the new empirical distribution.
      Throws:
      IncorrectDistributionParameterException - when any of the provided data is less than zero or the sum of all of them is not one or zero.
    • EmpiricalPar

      public EmpiricalPar(EmpiricalEntry[] entries) throws IncorrectDistributionParameterException
      Creates an empirical parameter with these entries (each entry contains a value and a probability). The Empirical can return not only an integer, but also directly an object, given the right probability table.
      Parameters:
      entries - Empirical entries.
      Throws:
      IncorrectDistributionParameterException
  • Method Details

    • getPDF

      public double[] getPDF()
      It returns the value of the parameters for the empirical distribution, that is the vector of double representing the probabilities provided by the user.
      Returns:
      array of double with the probability distribution function tabulated.
    • getCDF

      public double[] getCDF()
      It returns the value of the parameters for the empirical distribution, that is the vector of double representing the cumulative distribution function tabulated.
      Returns:
      array of double with the cumulative distribution function tabulated.
    • setPDF

      public void setPDF(double[] pdf) throws IncorrectDistributionParameterException
      It allows the user to change the value of the parameter of the empirical distribution. Takes an existent array of pdf and tries to convert it in a pdf for an empirical distribution, checking the conditions which must be respected.
      Parameters:
      pdf - array of double containing an existent pdf.
      Throws:
      IncorrectDistributionParameterException - if, among the provided data, there is a value less than zero or the sum of all of them is not one or zero.
    • check

      public boolean check()
      It controls if the parameter is correct or not. For the empirical distribution, the parameter is correct if the values in the pdf array are equal to or greater than zero and they sum up to one or zero.
      Specified by:
      check in interface AutoCheck
      Specified by:
      check in interface Parameter
      Overrides:
      check in class AbstractParameter
      Returns:
      boolean indicating if the parameter is correct or not.
    • guiCheck

      public static boolean guiCheck(String parameterName, Double value)
      Checks whether a parameter value is correct.
      Parameters:
      parameterName -
      value -
    • guiGetErrorMsg

      public static String guiGetErrorMsg(String parameterName)
    • getValue

      public Object getValue(int position)
      Returns the value in the corresponding position: generally only the empirical distribution needs to access this method (generates the random number then ask for the corresponding value).
      Parameters:
      position -
      Returns:
      value
    • getValues

      public Object[] getValues()
      Returns all the values.
      Returns:
      values