Class AbstractContinousPDF
- java.lang.Object
-
- de.uka.ipd.sdq.probfunction.math.apache.impl.AbstractContinousPDF
-
- All Implemented Interfaces:
IContinousPDF
,IProbabilityDensityFunction
,IProbabilityFunction
- Direct Known Subclasses:
ChiSquareDistribution
,ExponentialDistribution
,GammaDistribution
,LognormalDistribution
,NormalDistribution
,StudentTDistribution
,UniformDistribution
public abstract class AbstractContinousPDF extends Object implements IContinousPDF
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.math.distribution.AbstractContinuousDistribution
internalFunction
protected IRandomGenerator
sampleDrawer
-
Constructor Summary
Constructors Constructor Description AbstractContinousPDF(IRandomGenerator rng)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IProbabilityDensityFunction
add(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).double
cdf(double x)
Returns the distribution function F(x) as defined inumontreal.iro.lecuyer.probdist.Distribution#cdf(double)
void
checkConstrains()
checks whether the following constraints are fulfilled : the sum of all probabilities is one.double
density(double x)
Returns f(x), the density evaluated at x, as defined inumontreal.iro.lecuyer.probdist.ContinousDistribution#density(double)
IProbabilityDensityFunction
div(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).double
drawSample()
Generates a random number of the probability function's domain, whose distribution is defined by the probability function.double
getCoefficientOfVariance()
IProbabilityDensityFunction
getCumulativeFunction()
returns the cumulative probability function associated with this probability function.IProbabilityDensityFunction
getFourierTransform()
Computes the fourier transform of the probability density function.IProbabilityDensityFunction
getInverseFourierTransform()
Computes the inverse fourier transform of the probability density function.double
getProbabilitySum()
Computes the sum of all probabilities specified in the function.IUnit
getUnit()
Returns the unit of the probability functions domain.double
getVariance()
double
greaterThan(IProbabilityDensityFunction pdf)
Computes the probability that the random variable specified by this PDF is greater than the random variable specified by pdf.double
inverseF(double u)
Computes and returns the inverse distribution function x = F^{-1}(u).boolean
isInFrequencyDomain()
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).boolean
isInTimeDomain()
True, if the probability density function is the time domain (a time domain graph shows how a signal changes over time).double
lessThan(IProbabilityDensityFunction pdf)
Computes the probability that the random variable specified by this PDF is less than the random variable specified by pdf.IProbabilityDensityFunction
mult(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).double
probabilisticEquals(IProbabilityDensityFunction pdf)
Computes the probability that two random variables characterised by the given PDFs are equal.IProbabilityDensityFunction
scale(double scalar)
Scales a ProbabilityDensityFunctions on a "per value" basis:
h(x) = a * f(x)IProbabilityDensityFunction
shiftDomain(double scalar)
Shifts the domain values of the PDF by the given scalarIProbabilityDensityFunction
stretchDomain(double scalar)
Stretches the domain values of the PDF.IProbabilityDensityFunction
sub(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.IContinousPDF
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.AbstractContinuousDistribution internalFunction
-
sampleDrawer
protected IRandomGenerator sampleDrawer
-
-
Constructor Detail
-
AbstractContinousPDF
public AbstractContinousPDF(IRandomGenerator rng)
-
-
Method Detail
-
getCoefficientOfVariance
public double getCoefficientOfVariance()
- Specified by:
getCoefficientOfVariance
in interfaceIContinousPDF
-
getVariance
public double getVariance()
- Specified by:
getVariance
in interfaceIContinousPDF
-
getProbabilitySum
public double getProbabilitySum()
Description copied from interface:IProbabilityFunction
Computes 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:
getProbabilitySum
in interfaceIProbabilityFunction
- Returns:
- Sum of all probabilities in the function.
-
isInFrequencyDomain
public boolean isInFrequencyDomain()
Description copied from interface:IProbabilityFunction
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). This means it is the result of a Fourier transformation.- Specified by:
isInFrequencyDomain
in interfaceIProbabilityFunction
- Returns:
- True, if in frequency domain, false otherwise.
-
isInTimeDomain
public boolean isInTimeDomain()
Description copied from interface:IProbabilityFunction
True, 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:
isInTimeDomain
in 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)
- Specified by:
cdf
in interfaceIContinousPDF
- Parameters:
x
-- Returns:
- F(x)
-
density
public double density(double x)
Returns f(x), the density evaluated at x, as defined inumontreal.iro.lecuyer.probdist.ContinousDistribution#density(double)
- Specified by:
density
in interfaceIContinousPDF
- Parameters:
x
-- Returns:
- F(x)
-
drawSample
public double drawSample()
Description copied from interface:IProbabilityDensityFunction
Generates a random number of the probability function's domain, whose distribution is defined by the probability function.- Specified by:
drawSample
in interfaceIProbabilityDensityFunction
- Returns:
- A sample of the PDF's domain.
-
add
public IProbabilityDensityFunction add(IProbabilityDensityFunction pdf) throws FunctionsInDifferenDomainsException, UnknownPDFTypeException, IncompatibleUnitsException
Description copied from interface:IProbabilityDensityFunction
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). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
add
in 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:IProbabilityDensityFunction
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). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
div
in interfaceIProbabilityDensityFunction
- Parameters:
pdf
- g(x), probability density function to divide by.- Returns:
- The fraction of this function (f(x)) and pdf (g(x))
- Throws:
FunctionsInDifferenDomainsException
UnknownPDFTypeException
IncompatibleUnitsException
-
getCumulativeFunction
public IProbabilityDensityFunction getCumulativeFunction() throws FunctionNotInTimeDomainException
Description copied from interface:IProbabilityDensityFunction
returns the cumulative probability function associated with this probability function.- Specified by:
getCumulativeFunction
in interfaceIProbabilityDensityFunction
- Returns:
- the computed cumulative probability function.
- Throws:
FunctionNotInTimeDomainException
-
getFourierTransform
public IProbabilityDensityFunction getFourierTransform() throws FunctionNotInTimeDomainException
Description copied from interface:IProbabilityDensityFunction
Computes the fourier transform of the probability density function. Can only be applied if 'isInTimeDomain()' is true, otherwise a FunctionNotInTimeDomain exception is thrown.- Specified by:
getFourierTransform
in interfaceIProbabilityDensityFunction
- Returns:
- fourier transform of the PDF (in frequency domain)
- Throws:
FunctionNotInTimeDomainException
-
getInverseFourierTransform
public IProbabilityDensityFunction getInverseFourierTransform() throws FunctionNotInFrequencyDomainException
Description copied from interface:IProbabilityDensityFunction
Computes the inverse fourier transform of the probability density function. Can only be applied if 'isInFrequencyDomain()' is true, otherwise a FunctionNotInFrequencyDomainException is thrown.- Specified by:
getInverseFourierTransform
in 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:IProbabilityDensityFunction
Computes 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:
greaterThan
in 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:IProbabilityDensityFunction
Computes 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:
lessThan
in 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:IProbabilityDensityFunction
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). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
mult
in 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:IProbabilityDensityFunction
Computes the probability that two random variables characterised by the given PDFs are equal. Note that the randomvariables have to be independent.- Specified by:
probabilisticEquals
in 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:IProbabilityDensityFunction
Scales a ProbabilityDensityFunctions on a "per value" basis:
h(x) = a * f(x)- Specified by:
scale
in 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:IProbabilityDensityFunction
Shifts the domain values of the PDF by the given scalar- Specified by:
shiftDomain
in interfaceIProbabilityDensityFunction
- Returns:
- Throws:
DomainNotNumbersException
-
stretchDomain
public IProbabilityDensityFunction stretchDomain(double scalar)
Description copied from interface:IProbabilityDensityFunction
Stretches the domain values of the PDF. This is equivalent to the multiplication of the specified random variable by the given scalar.- Specified by:
stretchDomain
in interfaceIProbabilityDensityFunction
- Returns:
-
sub
public IProbabilityDensityFunction sub(IProbabilityDensityFunction pdf) throws FunctionsInDifferenDomainsException, UnknownPDFTypeException, IncompatibleUnitsException
Description copied from interface:IProbabilityDensityFunction
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). If not a FunctionsInDifferenDomainsException is thrown.- Specified by:
sub
in 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, InvalidSampleValueException
Description copied from interface:IProbabilityFunction
checks whether the following constraints are fulfilled : the sum of all probabilities is one. all values are greater or equal 0.
-
inverseF
public double 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.probdist
package.- Specified by:
inverseF
in interfaceIContinousPDF
- 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:IProbabilityFunction
Returns the unit of the probability functions domain.- Specified by:
getUnit
in interfaceIProbabilityFunction
- Returns:
- unit of the probability functions domain.
-
-