Class ProbabilityMassFunctionImpl

    • Constructor Detail

      • ProbabilityMassFunctionImpl

        protected ProbabilityMassFunctionImpl​(List<ISample> samples,
                                              IUnit unit,
                                              boolean hasOrderedDomain,
                                              boolean isInFrequencyDomain,
                                              IRandomGenerator generator)
    • Method Detail

      • add

        public IProbabilityMassFunction add​(IProbabilityMassFunction pmf)
                                     throws DifferentDomainsException
        Description copied from interface: IProbabilityMassFunction
        Adds the probabilities of two probability mass functions (pmf) on a 'per value' basis.
        h(x) = f(x) + g(x) (f = this, g = parameter pmf)
        For the addition, the domains of both pmfs have to be equal. This means that
      • * the value objects of the pmf's samples have to be of the same class and
      • * for each value object of the samples in function f (this) there is exactly one equal value object in the samples of function g (pmf) and vice versa. Here, equal means that Object.equal(...) returns true for both objects.

      • If the domain of both functions are not equal, a DifferentDomainsException is thrown.
Specified by:
add in interface IProbabilityMassFunction
Parameters:
pmf - Function to add.
Returns:
A new pmf that contains the sum of both.
Throws:
DifferentDomainsException - if the domains of both function differ.
Specified by:
mult in interface IProbabilityMassFunction
Parameters:
pmf - Function to multiply with.
Returns:
A new pmf that contains the product of both.
Throws:
DifferentDomainsException - if the domains of both function differ.