Class AbstractDiscretePDF
- java.lang.Object
-
- de.uka.ipd.sdq.probfunction.math.apache.impl.AbstractDiscretePDF
-
- All Implemented Interfaces:
IDiscretePDF,IProbabilityDensityFunction,IProbabilityFunction
- Direct Known Subclasses:
BinomialDistribution,PoissonDistribution,UniformIntDistribution
public abstract class AbstractDiscretePDF extends Object implements IDiscretePDF
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.math.distribution.AbstractIntegerDistributioninternalFunctionprotected IRandomGeneratorsampleDrawer
-
Constructor Summary
Constructors Constructor Description AbstractDiscretePDF()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IProbabilityDensityFunctionadd(IProbabilityDensityFunction pdf)Adds two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) + g(x)
An addition can only be performed if both functions are in the same domain (frequency or time).doublecdf(double x)Returns the distribution function F(x) as defined inumontreal.iro.lecuyer.probdist.Distribution#cdf(double)doublecdf(int x)Returns the distribution function F(x) as defined inumontreal.iro.lecuyer.probdist.Distribution#cdf(double)voidcheckConstrains()checks whether the following constraints are fulfilled : the sum of all probabilities is one.IProbabilityDensityFunctiondiv(IProbabilityDensityFunction pdf)Divides two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) / g(x)
A division can only be performed if both functions are in the same domain (frequency or time).doubledrawSample()Generates a random number of the probability function's domain, whose distribution is defined by the probability function.doublegetCoefficientOfVariance()IProbabilityDensityFunctiongetCumulativeFunction()returns the cumulative probability function associated with this probability function.IProbabilityDensityFunctiongetFourierTransform()Computes the fourier transform of the probability density function.IProbabilityDensityFunctiongetInverseFourierTransform()Computes the inverse fourier transform of the probability density function.doublegetProbabilitySum()Computes the sum of all probabilities specified in the function.IUnitgetUnit()Returns the unit of the probability functions domain.doublegetVariance()doublegreaterThan(IProbabilityDensityFunction pdf)Computes the probability that the random variable specified by this PDF is greater than the random variable specified by pdf.intinverseF(double u)Computes and returns the inverse distribution function x = F^{-1}(u).booleanisInFrequencyDomain()True, if the probability density function is in the frequency domain (frequency domain graph shows how much of the signal lies within each given frequency band over a range of frequencies).booleanisInTimeDomain()True, if the probability density function is the time domain (a time domain graph shows how a signal changes over time).doublelessThan(IProbabilityDensityFunction pdf)Computes the probability that the random variable specified by this PDF is less than the random variable specified by pdf.IProbabilityDensityFunctionmult(IProbabilityDensityFunction pdf)Multiplies two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) * g(x)
A multiplication can only be performed if both functions are in the same domain (frequency or time).doubleprobabilisticEquals(IProbabilityDensityFunction pdf)Computes the probability that two random variables characterised by the given PDFs are equal.doubleprobability(int x)Returns f(x), the probability evaluated at xIProbabilityDensityFunctionscale(double scalar)Scales a ProbabilityDensityFunctions on a "per value" basis:
h(x) = a * f(x)IProbabilityDensityFunctionshiftDomain(double scalar)Shifts the domain values of the PDF by the given scalarIProbabilityDensityFunctionstretchDomain(double scalar)Stretches the domain values of the PDF.IProbabilityDensityFunctionsub(IProbabilityDensityFunction pdf)Subtracts two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) - g(x)
A substraction can only be performed if both functions are in the same domain (frequency or time).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.uka.ipd.sdq.probfunction.math.IDiscretePDF
getMean, getStandardDeviation, getXinf, getXsup
-
Methods inherited from interface de.uka.ipd.sdq.probfunction.math.IProbabilityDensityFunction
getLowerDomainBorder
-
Methods inherited from interface de.uka.ipd.sdq.probfunction.math.IProbabilityFunction
getArithmeticMeanValue, getMedian, getPercentile, hasOrderedDomain
-
-
-
-
Field Detail
-
internalFunction
protected org.apache.commons.math.distribution.AbstractIntegerDistribution internalFunction
-
sampleDrawer
protected IRandomGenerator sampleDrawer
-
-
Method Detail
-
cdf
public double cdf(int x)
Returns the distribution function F(x) as defined inumontreal.iro.lecuyer.probdist.Distribution#cdf(double)- Specified by:
cdfin interfaceIDiscretePDF- Parameters:
x-- Returns:
- F(x)
-
getCoefficientOfVariance
public double getCoefficientOfVariance()
-
getVariance
public double getVariance()
- Specified by:
getVariancein interfaceIDiscretePDF
-
getProbabilitySum
public double getProbabilitySum()
Description copied from interface:IProbabilityFunctionComputes the sum of all probabilities specified in the function. For pdfs this is the area under the graph; for pmfs the sum of all probabilities.- Specified by:
getProbabilitySumin interfaceIProbabilityFunction- Returns:
- Sum of all probabilities in the function.
-
probability
public double probability(int x)
Description copied from interface:IDiscretePDFReturns f(x), the probability evaluated at x- Specified by:
probabilityin interfaceIDiscretePDF- Returns:
- f(x)
-
isInFrequencyDomain
public boolean isInFrequencyDomain()
Description copied from interface:IProbabilityFunctionTrue, if the probability density function is in the frequency domain (frequency domain graph shows how much of the signal lies within each given frequency band over a range of frequencies). This means it is the result of a Fourier transformation.- Specified by:
isInFrequencyDomainin interfaceIProbabilityFunction- Returns:
- True, if in frequency domain, false otherwise.
-
isInTimeDomain
public boolean isInTimeDomain()
Description copied from interface:IProbabilityFunctionTrue, if the probability density function is the time domain (a time domain graph shows how a signal changes over time). This means that it is not a result of a Fourier transform.- Specified by:
isInTimeDomainin interfaceIProbabilityFunction- Returns:
- True, if in time domain; false otherwise.
-
cdf
public double cdf(double x)
Returns the distribution function F(x) as defined inumontreal.iro.lecuyer.probdist.Distribution#cdf(double)- Parameters:
x-- Returns:
- F(x)
-
drawSample
public double drawSample()
Description copied from interface:IProbabilityDensityFunctionGenerates a random number of the probability function's domain, whose distribution is defined by the probability function.- Specified by:
drawSamplein interfaceIProbabilityDensityFunction- Returns:
- A sample of the PDF's domain.
-
inverseF
public int inverseF(double u)
Computes and returns the inverse distribution function x = F^{-1}(u). This can be used to get the quantiles of the distribution. Pass 0.9 to get the x value of this function for which this.cdf(x) = 0.9 holds. Uses the implementation of the concrete function in theumontreal.iro.lecuyer.probdistpackage.- Specified by:
inverseFin interfaceIDiscretePDF- Parameters:
u- - value in the interval [0, 1] for which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
-
getUnit
public IUnit getUnit()
Description copied from interface:IProbabilityFunctionReturns the unit of the probability functions domain.- Specified by:
getUnitin interfaceIProbabilityFunction- Returns:
- unit of the probability functions domain.
-
add
public IProbabilityDensityFunction add(IProbabilityDensityFunction pdf) throws FunctionsInDifferenDomainsException, UnknownPDFTypeException, IncompatibleUnitsException
Description copied from interface:IProbabilityDensityFunctionAdds two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) + g(x)
An addition can only be performed if both functions are in the same domain (frequency or time). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
addin interfaceIProbabilityDensityFunction- Parameters:
pdf- g(x), probability density function to add.- Returns:
- The sum of this function (f(x)) and pdf (g(x))
- Throws:
FunctionsInDifferenDomainsException- Thrown if both functions are in different domains.UnknownPDFTypeException- Thrown if one of the function is of an unknown type (not SamplePDf or BoxedPDF).IncompatibleUnitsException- Thrown if both functions have units that do not match.
-
div
public IProbabilityDensityFunction div(IProbabilityDensityFunction pdf) throws FunctionsInDifferenDomainsException, UnknownPDFTypeException, IncompatibleUnitsException
Description copied from interface:IProbabilityDensityFunctionDivides two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) / g(x)
A division can only be performed if both functions are in the same domain (frequency or time). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
divin interfaceIProbabilityDensityFunction- Parameters:
pdf- g(x), probability density function to divide by.- Returns:
- The fraction of this function (f(x)) and pdf (g(x))
- Throws:
FunctionsInDifferenDomainsExceptionUnknownPDFTypeExceptionIncompatibleUnitsException
-
getCumulativeFunction
public IProbabilityDensityFunction getCumulativeFunction() throws FunctionNotInTimeDomainException
Description copied from interface:IProbabilityDensityFunctionreturns the cumulative probability function associated with this probability function.- Specified by:
getCumulativeFunctionin interfaceIProbabilityDensityFunction- Returns:
- the computed cumulative probability function.
- Throws:
FunctionNotInTimeDomainException
-
getFourierTransform
public IProbabilityDensityFunction getFourierTransform() throws FunctionNotInTimeDomainException
Description copied from interface:IProbabilityDensityFunctionComputes the fourier transform of the probability density function. Can only be applied if 'isInTimeDomain()' is true, otherwise a FunctionNotInTimeDomain exception is thrown.- Specified by:
getFourierTransformin interfaceIProbabilityDensityFunction- Returns:
- fourier transform of the PDF (in frequency domain)
- Throws:
FunctionNotInTimeDomainException
-
getInverseFourierTransform
public IProbabilityDensityFunction getInverseFourierTransform() throws FunctionNotInFrequencyDomainException
Description copied from interface:IProbabilityDensityFunctionComputes the inverse fourier transform of the probability density function. Can only be applied if 'isInFrequencyDomain()' is true, otherwise a FunctionNotInFrequencyDomainException is thrown.- Specified by:
getInverseFourierTransformin interfaceIProbabilityDensityFunction- Returns:
- inverse fourier transform of the PDF (in time domain)
- Throws:
FunctionNotInFrequencyDomainException
-
greaterThan
public double greaterThan(IProbabilityDensityFunction pdf) throws ProbabilityFunctionException
Description copied from interface:IProbabilityDensityFunctionComputes the probability that the random variable specified by this PDF is greater than the random variable specified by pdf. Note that the randomvariables have to be independent.- Specified by:
greaterThanin interfaceIProbabilityDensityFunction- Parameters:
pdf- PDF to compare to.- Returns:
- Probability X_this > X_pdf
- Throws:
ProbabilityFunctionException
-
lessThan
public double lessThan(IProbabilityDensityFunction pdf) throws ProbabilityFunctionException
Description copied from interface:IProbabilityDensityFunctionComputes the probability that the random variable specified by this PDF is less than the random variable specified by pdf. Note that the randomvariables have to be independent.- Specified by:
lessThanin interfaceIProbabilityDensityFunction- Parameters:
pdf- PDF to compare to.- Returns:
- Probability X_this < X_pdf
- Throws:
ProbabilityFunctionException
-
mult
public IProbabilityDensityFunction mult(IProbabilityDensityFunction pdf) throws FunctionsInDifferenDomainsException, UnknownPDFTypeException, IncompatibleUnitsException
Description copied from interface:IProbabilityDensityFunctionMultiplies two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) * g(x)
A multiplication can only be performed if both functions are in the same domain (frequency or time). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
multin interfaceIProbabilityDensityFunction- Parameters:
pdf- g(x), probability density function to multiply with.- Returns:
- The product of this function (f(x)) and pdf (g(x))
- Throws:
FunctionsInDifferenDomainsException- Thrown if both functions are in different domains.UnknownPDFTypeException- Thrown if one of the function is of an unknown type (not SamplePDf or BoxedPDF).IncompatibleUnitsException- Thrown if both functions have units that do not match.
-
probabilisticEquals
public double probabilisticEquals(IProbabilityDensityFunction pdf) throws ProbabilityFunctionException
Description copied from interface:IProbabilityDensityFunctionComputes the probability that two random variables characterised by the given PDFs are equal. Note that the randomvariables have to be independent.- Specified by:
probabilisticEqualsin interfaceIProbabilityDensityFunction- Parameters:
pdf- PDF to compare to.- Returns:
- Probability that the two random variables characterised by the PDFs are equal.
- Throws:
ProbabilityFunctionException
-
scale
public IProbabilityDensityFunction scale(double scalar)
Description copied from interface:IProbabilityDensityFunctionScales a ProbabilityDensityFunctions on a "per value" basis:
h(x) = a * f(x)- Specified by:
scalein interfaceIProbabilityDensityFunction- Parameters:
scalar- a, value to scale with.- Returns:
- The scaled function a*f(x)
-
shiftDomain
public IProbabilityDensityFunction shiftDomain(double scalar) throws DomainNotNumbersException
Description copied from interface:IProbabilityDensityFunctionShifts the domain values of the PDF by the given scalar- Specified by:
shiftDomainin interfaceIProbabilityDensityFunction- Returns:
- Throws:
DomainNotNumbersException
-
stretchDomain
public IProbabilityDensityFunction stretchDomain(double scalar)
Description copied from interface:IProbabilityDensityFunctionStretches the domain values of the PDF. This is equivalent to the multiplication of the specified random variable by the given scalar.- Specified by:
stretchDomainin interfaceIProbabilityDensityFunction- Returns:
-
sub
public IProbabilityDensityFunction sub(IProbabilityDensityFunction pdf) throws FunctionsInDifferenDomainsException, UnknownPDFTypeException, IncompatibleUnitsException
Description copied from interface:IProbabilityDensityFunctionSubtracts two ProbabilityDensityFunctions on a "per value" basis:
h(x) = f(x) - g(x)
A substraction can only be performed if both functions are in the same domain (frequency or time). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
subin interfaceIProbabilityDensityFunction- Parameters:
pdf- g(x), probability density function to substract.- Returns:
- The difference of this function (f(x)) and pdf (g(x))
- Throws:
FunctionsInDifferenDomainsException- Thrown if both functions are in different domains.UnknownPDFTypeException- Thrown if one of the function is of an unknown type (not SamplePDf or BoxedPDF).IncompatibleUnitsException- Thrown if both functions have units that do not match.
-
checkConstrains
public void checkConstrains() throws NegativeDistanceException, ProbabilitySumNotOneException, FunctionNotInTimeDomainException, UnitNotSetException, UnitNameNotSetException, InvalidSampleValueExceptionDescription copied from interface:IProbabilityFunctionchecks whether the following constraints are fulfilled : the sum of all probabilities is one. all values are greater or equal 0.
-
-