Class ProbabilityFunctionFactoryImpl
java.lang.Object
de.uka.ipd.sdq.probfunction.math.impl.ProbabilityFunctionFactoryImpl
- All Implemented Interfaces:
IProbabilityFunctionFactory
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected static final ProbabilityFunctionFactoryImpl
Fields inherited from interface de.uka.ipd.sdq.probfunction.math.IProbabilityFunctionFactory
eINSTANCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateBoxedPDF
(List<IContinuousSample> samples, IRandomGenerator randomGenerator, IUnit unit) createBoxedPDF
(List<IContinuousSample> samples, IUnit unit) Creates a new BoxedPDF, whose boxes are defined by 'samples'.createBoxedPDF
(List<IContinuousSample> samples, IUnit unit, IRandomGenerator generator) createContinuousSample
(double value, double d) Creates a new ContinuousSample with the attributes value and probability set.Creates new Unit with name DEFAULT_UNIT_NAME, which is "ms".createDiracImpulse
(int numOfSamplingPoints, double distance, IUnit unit) creates a distribution function, wich represents a dirac impulse.createImpulseAt
(int pos, int numOfSamplingPoints, double distance, IUnit unit) Creates a distribution function, which describes a random variable with a constant outcome.createPMFFromMeasurements
(Boolean[] measurements, IUnit unit, boolean hasOrderedDomain) createPMFFromMeasurements
(Double[] measurements, double epsilon, IUnit unit, boolean hasOrderedDomain) createPMFFromMeasurements
(Integer[] measurements, IUnit unit, boolean hasOrderedDomain) createPMFFromMeasurements
(String[] measurements, IUnit unit, boolean hasOrderedDomain) createProbabilityMassFunction
(List<ISample> samples, IUnit unit, boolean hasOrderedDomain) Creates a new ProbabilityMassFunction whose samples are set to 'samples'.createSample
(Object value, double probability) Creates a new Sample with the attributes value and probability set.createSamplePDFFromComplex
(double distance, List<org.apache.commons.math.complex.Complex> samples, boolean isInFrequencyDomain, IUnit unit) Creates a new SamplePDF instace whose distance is set to 'distance' and whose sampling points are set to samples.createSamplePDFFromComplex
(double distance, List<org.apache.commons.math.complex.Complex> samples, boolean isInFrequencyDomain, IUnit unit, IRandomGenerator generator) createSamplePDFFromComplex
(double distance, List<org.apache.commons.math.complex.Complex> values, IUnit unit) createSamplePDFFromComplex
(double distance, List<org.apache.commons.math.complex.Complex> samples, IUnit unit, IRandomGenerator generator) createSamplePDFFromDouble
(double distance, List<Double> values, boolean isInFrequencyDomain, IUnit unit) createSamplePDFFromDouble
(double distance, List<Double> values, boolean isInFrequencyDomain, IUnit unit, IRandomGenerator generator) createSamplePDFFromDouble
(double distance, List<Double> values, IUnit unit) Creates a new SamplePDF instace whose distance is set to 'distance' and whose sampling points are set to samples.createSamplePDFFromDouble
(double distance, List<Double> values, IUnit unit, IRandomGenerator generator) createSamplePDFFromMeasurements
(double distance, List<Double> measurements, IUnit unit) createUnit
(String unitName) Creates new Unit with name unitName.createZeroFunction
(int numOfSamplingPoints, double distance, IUnit unit) creates a distribution function, wich consists of numOfSamplingspoints zeros.void
setPDFFactory
(IPDFFactory pdfFactory) void
setRandomGenerator
(IRandomGenerator randomGenerator) Set the random generator to use to the passed one.transformBoxedToSamplePDF
(IBoxedPDF bpdf, double distance) Converts a arbitrary PDF to a BoxedPDF.Converts a model object to a function object with the same attributes.transformToBoxedPDF
(ProbabilityDensityFunction epdf, IRandomGenerator randomNumberGenerator) Converts a model object to a function object with the same attributes.Converts a model object to a function object with the same attributes.Converts a function object to a model object with the same attributes.Converts a function object to a model object with the same attributes.Converts a function object to a model object with the same attributes.Converts a function object to a model object with the same attributes.transformToModelSample
(ISample sample) Converts a function object to a model object with the same attributes.Converts a function object to a model object with the same attributes.Converts a function object to a model object with the same attributes.Converts a model object to a function object with the same attributes.transformToPDF
(ProbabilityDensityFunction ePDF, IRandomGenerator randomGenerator) TODO: support Pois, Binom, UniInt and UniDouble.Converts a model object to a function object with the same attributes.transformToPMF
(ProbabilityMassFunction epmf, IRandomGenerator randomGenerator) Converts a model object to a function object with the same attributes.transformToSample
(Sample eSample) Converts a model object to a function object with the same attributes.Converts a arbitrary PDF to a SamplePDF.transformToSamplePDF
(IProbabilityDensityFunction pdf, double newDistance) Converts a arbitrary PDF to a SamplePDF.Converts a model object to a function object with the same attributes.transformToSamplePDF
(ProbabilityDensityFunction epdf, IRandomGenerator randomGenerator) transformToUnit
(String unitSpecification) Converts a model object to a function object with the same attributes.
-
Field Details
-
DEFAULT_UNIT_NAME
- See Also:
-
factoryInstance
-
-
Constructor Details
-
ProbabilityFunctionFactoryImpl
-
-
Method Details
-
getPDFFactory
- Specified by:
getPDFFactory
in interfaceIProbabilityFunctionFactory
-
setPDFFactory
-
transformToBoxedPDF
public IBoxedPDF transformToBoxedPDF(ProbabilityDensityFunction epdf) throws ProbabilitySumNotOneException, DoubleSampleException Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToBoxedPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
epdf
- Object to transform.- Returns:
- New BoxedPDF instance.
- Throws:
ProbabilitySumNotOneException
DoubleSampleException
-
transformToBoxedPDF
public IBoxedPDF transformToBoxedPDF(ProbabilityDensityFunction epdf, IRandomGenerator randomNumberGenerator) throws ProbabilitySumNotOneException, DoubleSampleException Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToBoxedPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
epdf
- Object to transform.randomNumberGenerator
- Number generator to use- Returns:
- New BoxedPDF instance.
- Throws:
ProbabilitySumNotOneException
DoubleSampleException
-
transformToSamplePDF
public ISamplePDF transformToSamplePDF(ProbabilityDensityFunction epdf) throws UnknownPDFTypeException, ProbabilitySumNotOneException, DoubleSampleException Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToSamplePDF
in interfaceIProbabilityFunctionFactory
- Parameters:
epdf
- Object to transform.- Returns:
- New SamplePDF instance.
- Throws:
UnknownPDFTypeException
- Thrown in case pdf is neither a BoxedPDF nor a SamplePDFProbabilitySumNotOneException
DoubleSampleException
-
transformToSamplePDF
public ISamplePDF transformToSamplePDF(ProbabilityDensityFunction epdf, IRandomGenerator randomGenerator) throws UnknownPDFTypeException, ProbabilitySumNotOneException, DoubleSampleException -
transformToPMF
Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToPMF
in interfaceIProbabilityFunctionFactory
- Parameters:
epmf
- Object to transform.- Returns:
- New ProbabilityMassFunction instance.
-
transformToPMF
public IProbabilityMassFunction transformToPMF(ProbabilityMassFunction epmf, IRandomGenerator randomGenerator) Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToPMF
in interfaceIProbabilityFunctionFactory
- Parameters:
epmf
- Object to transform.- Returns:
- New ProbabilityMassFunction instance.
-
createBoxedPDF
public IBoxedPDF createBoxedPDF(List<IContinuousSample> samples, IUnit unit) throws DoubleSampleException Description copied from interface:IProbabilityFunctionFactory
Creates a new BoxedPDF, whose boxes are defined by 'samples'.- Specified by:
createBoxedPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
samples
- List of ContinuousSamples, which defines the upper right corners of the PDF's boxes. The list may be unsorted. The values of all samples must be greater or equal to zero.- Returns:
- New BoxedPDF instance.
- Throws:
DoubleSampleException
-
createBoxedPDF
public IBoxedPDF createBoxedPDF(List<IContinuousSample> samples, IRandomGenerator randomGenerator, IUnit unit) throws DoubleSampleException - Throws:
DoubleSampleException
-
createBoxedPDF
public IBoxedPDF createBoxedPDF(List<IContinuousSample> samples, IUnit unit, IRandomGenerator generator) throws DoubleSampleException - Throws:
DoubleSampleException
-
createContinuousSample
Description copied from interface:IProbabilityFunctionFactory
Creates a new ContinuousSample with the attributes value and probability set.- Specified by:
createContinuousSample
in interfaceIProbabilityFunctionFactory
- Returns:
- New ContinuousSample instance.
-
createDefaultUnit
Description copied from interface:IProbabilityFunctionFactory
Creates new Unit with name DEFAULT_UNIT_NAME, which is "ms".- Specified by:
createDefaultUnit
in interfaceIProbabilityFunctionFactory
- Returns:
- New Unit instance.
-
createDiracImpulse
Description copied from interface:IProbabilityFunctionFactory
creates a distribution function, wich represents a dirac impulse. The returned function consists of numOfSamplingPoints equidistant points.- Specified by:
createDiracImpulse
in interfaceIProbabilityFunctionFactory
- Parameters:
numOfSamplingPoints
- number of points.distance
- distance between each two points.unit
- TODO- Returns:
- a new probability density function with entered parameters.
-
createImpulseAt
Description copied from interface:IProbabilityFunctionFactory
Creates a distribution function, which describes a random variable with a constant outcome. In this case, it is given by distance * pos.- Specified by:
createImpulseAt
in interfaceIProbabilityFunctionFactory
- Returns:
- a new probability density function with entered parameters.
-
createProbabilityMassFunction
public IProbabilityMassFunction createProbabilityMassFunction(List<ISample> samples, IUnit unit, boolean hasOrderedDomain) Description copied from interface:IProbabilityFunctionFactory
Creates a new ProbabilityMassFunction whose samples are set to 'samples'. If the samples are marked as ordered, they will be sorted and stochastic values such as median and percentile are available.- Specified by:
createProbabilityMassFunction
in interfaceIProbabilityFunctionFactory
- Parameters:
samples
- List of samples for the PMF.hasOrderedDomain
- Marks a set as ordered.- Returns:
- New ProbabilityMassFunction instance.
-
createPMFFromMeasurements
public IProbabilityMassFunction createPMFFromMeasurements(Boolean[] measurements, IUnit unit, boolean hasOrderedDomain) - Specified by:
createPMFFromMeasurements
in interfaceIProbabilityFunctionFactory
- Returns:
-
createPMFFromMeasurements
public IProbabilityMassFunction createPMFFromMeasurements(Double[] measurements, double epsilon, IUnit unit, boolean hasOrderedDomain) - Specified by:
createPMFFromMeasurements
in interfaceIProbabilityFunctionFactory
- Returns:
-
createPMFFromMeasurements
public IProbabilityMassFunction createPMFFromMeasurements(String[] measurements, IUnit unit, boolean hasOrderedDomain) - Specified by:
createPMFFromMeasurements
in interfaceIProbabilityFunctionFactory
- Returns:
-
createPMFFromMeasurements
public IProbabilityMassFunction createPMFFromMeasurements(Integer[] measurements, IUnit unit, boolean hasOrderedDomain) - Specified by:
createPMFFromMeasurements
in interfaceIProbabilityFunctionFactory
- Returns:
-
createSample
Description copied from interface:IProbabilityFunctionFactory
Creates a new Sample with the attributes value and probability set.- Specified by:
createSample
in interfaceIProbabilityFunctionFactory
- Returns:
- New Sample instance.
-
createSamplePDFFromComplex
public ISamplePDF createSamplePDFFromComplex(double distance, List<org.apache.commons.math.complex.Complex> values, IUnit unit) - Specified by:
createSamplePDFFromComplex
in interfaceIProbabilityFunctionFactory
- Returns:
-
createSamplePDFFromComplex
public ISamplePDF createSamplePDFFromComplex(double distance, List<org.apache.commons.math.complex.Complex> samples, boolean isInFrequencyDomain, IUnit unit) Description copied from interface:IProbabilityFunctionFactory
Creates a new SamplePDF instace whose distance is set to 'distance' and whose sampling points are set to samples.- Specified by:
createSamplePDFFromComplex
in interfaceIProbabilityFunctionFactory
- Parameters:
distance
- Distance between the sampling points stored in samples.samples
- Sampling points of the approximated PDF.isInFrequencyDomain
- Indicates whether the values are in frequency domain (true) or time domain (false).unit
- TODO- Returns:
- New instance of SamplePDF with set attributes.
-
createSamplePDFFromComplex
public ISamplePDF createSamplePDFFromComplex(double distance, List<org.apache.commons.math.complex.Complex> samples, IUnit unit, IRandomGenerator generator) - Specified by:
createSamplePDFFromComplex
in interfaceIProbabilityFunctionFactory
- Returns:
-
createSamplePDFFromComplex
public ISamplePDF createSamplePDFFromComplex(double distance, List<org.apache.commons.math.complex.Complex> samples, boolean isInFrequencyDomain, IUnit unit, IRandomGenerator generator) - Specified by:
createSamplePDFFromComplex
in interfaceIProbabilityFunctionFactory
- Returns:
-
createSamplePDFFromDouble
Description copied from interface:IProbabilityFunctionFactory
Creates a new SamplePDF instace whose distance is set to 'distance' and whose sampling points are set to samples. As the sampling points are complex values in general, this function sets only the real part of the values. The imaginary part is set to zero.- Specified by:
createSamplePDFFromDouble
in interfaceIProbabilityFunctionFactory
- Parameters:
distance
- Distance between the sampling points stored in samples.values
- Sampling points of the approximated PDF.unit
- TODO- Returns:
- New instance of SamplePDF with set attributes.
-
createSamplePDFFromDouble
public ISamplePDF createSamplePDFFromDouble(double distance, List<Double> values, boolean isInFrequencyDomain, IUnit unit) - Specified by:
createSamplePDFFromDouble
in interfaceIProbabilityFunctionFactory
- Returns:
-
createSamplePDFFromDouble
public ISamplePDF createSamplePDFFromDouble(double distance, List<Double> values, IUnit unit, IRandomGenerator generator) - Specified by:
createSamplePDFFromDouble
in interfaceIProbabilityFunctionFactory
- Returns:
-
createSamplePDFFromDouble
public ISamplePDF createSamplePDFFromDouble(double distance, List<Double> values, boolean isInFrequencyDomain, IUnit unit, IRandomGenerator generator) - Specified by:
createSamplePDFFromDouble
in interfaceIProbabilityFunctionFactory
- Returns:
-
createSamplePDFFromMeasurements
public ISamplePDF createSamplePDFFromMeasurements(double distance, List<Double> measurements, IUnit unit) - Specified by:
createSamplePDFFromMeasurements
in interfaceIProbabilityFunctionFactory
- Returns:
-
createUnit
Description copied from interface:IProbabilityFunctionFactory
Creates new Unit with name unitName.- Specified by:
createUnit
in interfaceIProbabilityFunctionFactory
- Parameters:
unitName
- Name of the unit.- Returns:
- New Unit instance.
-
createZeroFunction
Description copied from interface:IProbabilityFunctionFactory
creates a distribution function, wich consists of numOfSamplingspoints zeros.- Specified by:
createZeroFunction
in interfaceIProbabilityFunctionFactory
- Parameters:
numOfSamplingPoints
- number of points.distance
- distance between each two points.- Returns:
- a new "zeros" DistributionFunction.
-
transformToBoxedPDF
public IBoxedPDF transformToBoxedPDF(IProbabilityDensityFunction pdf) throws UnknownPDFTypeException, DoubleSampleException, FunctionNotInTimeDomainException Description copied from interface:IProbabilityFunctionFactory
Converts a arbitrary PDF to a BoxedPDF. So far, only two cases are supported: The input PDF is a BoxedPDF, then a reference to the original PDF is returned or the input pdf is a SamplePDF, then the a new BoxedPDF is created from the SamplePDF.- Specified by:
transformToBoxedPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
pdf
- PDF to transform.- Returns:
- Either a reference to the input PDF or a new BoxedPDF with the same properties as the input pdf.
- Throws:
UnknownPDFTypeException
- Thrown in case pdf is neither a BoxedPDF nor a SamplePDF.DoubleSampleException
FunctionNotInTimeDomainException
-
transformToModelBoxedPDF
public BoxedPDF transformToModelBoxedPDF(IProbabilityDensityFunction pdf) throws UnknownPDFTypeException, DoubleSampleException, FunctionNotInTimeDomainException Description copied from interface:IProbabilityFunctionFactory
Converts a function object to a model object with the same attributes.- Specified by:
transformToModelBoxedPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
pdf
- Object to transform.- Returns:
- New BoxedPDF instance.
- Throws:
DoubleSampleException
FunctionNotInTimeDomainException
UnknownPDFTypeException
-
transformToModelPDF
public ProbabilityDensityFunction transformToModelPDF(IProbabilityDensityFunction pdf) throws UnknownPDFTypeException, DoubleSampleException, FunctionNotInTimeDomainException Description copied from interface:IProbabilityFunctionFactory
Converts a function object to a model object with the same attributes.- Specified by:
transformToModelPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
pdf
- Object to transform.- Returns:
- New ProbabilityDensityFunction instance.
- Throws:
DoubleSampleException
FunctionNotInTimeDomainException
UnknownPDFTypeException
-
transformToModelPMF
Description copied from interface:IProbabilityFunctionFactory
Converts a function object to a model object with the same attributes.- Specified by:
transformToModelPMF
in interfaceIProbabilityFunctionFactory
- Parameters:
pmf
- Object to transform.- Returns:
- New ProbabilityMassFunction instance.
-
transformToModelSamplePDF
public SamplePDF transformToModelSamplePDF(IProbabilityDensityFunction pdf) throws UnknownPDFTypeException Description copied from interface:IProbabilityFunctionFactory
Converts a function object to a model object with the same attributes.- Specified by:
transformToModelSamplePDF
in interfaceIProbabilityFunctionFactory
- Parameters:
pdf
- Object to transform.- Returns:
- New SamplePDF instance.
- Throws:
UnknownPDFTypeException
-
transformToPDF
public IProbabilityDensityFunction transformToPDF(ProbabilityDensityFunction ePDF) throws UnknownPDFTypeException, ProbabilitySumNotOneException, DoubleSampleException Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes. (BoxedPDF -> IBoxedPDF, SamplePDF -> ISamplePDF)- Specified by:
transformToPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
ePDF
- Object to transform.- Returns:
- New ProbabilityDensityFunction instance.
- Throws:
ProbabilitySumNotOneException
DoubleSampleException
UnknownPDFTypeException
-
transformToPDF
public IProbabilityDensityFunction transformToPDF(ProbabilityDensityFunction ePDF, IRandomGenerator randomGenerator) throws UnknownPDFTypeException, ProbabilitySumNotOneException, DoubleSampleException TODO: support Pois, Binom, UniInt and UniDouble. They need to be added to the probfunction metamodel and then handled here.- Specified by:
transformToPDF
in interfaceIProbabilityFunctionFactory
- Parameters:
ePDF
- Object to transform.- Returns:
- New ProbabilityDensityFunction instance.
- Throws:
ProbabilitySumNotOneException
DoubleSampleException
UnknownPDFTypeException
-
transformToSamplePDF
public ISamplePDF transformToSamplePDF(IProbabilityDensityFunction pdf) throws UnknownPDFTypeException Description copied from interface:IProbabilityFunctionFactory
Converts a arbitrary PDF to a SamplePDF. So far, only two cases are supported: The input PDF is a SamplePDF, then a reference to the original PDF is returned or the input pdf is a BoxedPDF, then the a new SamplePDF is created from the BoxedPDF.- Specified by:
transformToSamplePDF
in interfaceIProbabilityFunctionFactory
- Parameters:
pdf
- PDF to transform.- Returns:
- Either a reference to the input PDF or a new SamplePDF with the same properties as the input pdf.
- Throws:
UnknownPDFTypeException
- Thrown in case pdf is neither a BoxedPDF nor a SamplePDF.
-
transformToSamplePDF
public ISamplePDF transformToSamplePDF(IProbabilityDensityFunction pdf, double newDistance) throws UnknownPDFTypeException, NegativeDistanceException, FunctionNotInTimeDomainException Description copied from interface:IProbabilityFunctionFactory
Converts a arbitrary PDF to a SamplePDF. So far, only two cases are supported: The input PDF is a SamplePDF, then a reference to a new Sample PDF with the given distance is returned or the input pdf is a BoxedPDF, then a new SamplePDF is created from the BoxedPDF.- Specified by:
transformToSamplePDF
in interfaceIProbabilityFunctionFactory
- Parameters:
pdf
- PDF to transform.newDistance
- the new distance- Returns:
- Either a reference to the input PDF or a new SamplePDF with the same properties as the input pdf.
- Throws:
UnknownPDFTypeException
- Thrown in case pdf is neither a BoxedPDF nor a SamplePDF.NegativeDistanceException
FunctionNotInTimeDomainException
-
transformToContinuousSample
Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToContinuousSample
in interfaceIProbabilityFunctionFactory
- Parameters:
eSample
- Object to transform.- Returns:
- New ContinuousSample instance.
-
transformToModelContinuousSample
Description copied from interface:IProbabilityFunctionFactory
Converts a function object to a model object with the same attributes.- Specified by:
transformToModelContinuousSample
in interfaceIProbabilityFunctionFactory
- Parameters:
sample
- Object to transform.- Returns:
- New ContinuousSample instance.
-
transformToModelSample
Description copied from interface:IProbabilityFunctionFactory
Converts a function object to a model object with the same attributes.- Specified by:
transformToModelSample
in interfaceIProbabilityFunctionFactory
- Parameters:
sample
- Object to transform.- Returns:
- New Sample instance.
-
transformToModelUnitSpecification
Description copied from interface:IProbabilityFunctionFactory
Converts a function object to a model object with the same attributes.- Specified by:
transformToModelUnitSpecification
in interfaceIProbabilityFunctionFactory
- Parameters:
unit
- Object to transform.- Returns:
- New Unit instance.
-
transformToSample
Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToSample
in interfaceIProbabilityFunctionFactory
- Parameters:
eSample
- Object to transform.- Returns:
- New Sample instance.
-
transformToUnit
Description copied from interface:IProbabilityFunctionFactory
Converts a model object to a function object with the same attributes.- Specified by:
transformToUnit
in interfaceIProbabilityFunctionFactory
- Returns:
- New Unit instance.
-
getInstance
-
transformBoxedToSamplePDF
-
setRandomGenerator
Description copied from interface:IProbabilityFunctionFactory
Set the random generator to use to the passed one. If this method is never called, theDefaultRandomGenerator
is used. This method can be called at any time, however, to get consistent results it should be called before retrieving any functions from this factory.- Specified by:
setRandomGenerator
in interfaceIProbabilityFunctionFactory
-
getRandomGenerator
- Specified by:
getRandomGenerator
in interfaceIProbabilityFunctionFactory
-