Class CompareOperation

    • Constructor Detail

      • CompareOperation

        public CompareOperation()
    • Method Detail

      • compare

        public IProbabilityMassFunction compare​(Object left,
                                                Object right)
        Compares to objects that represent the left-hand side and the right-hand side of a comparison expression.
        Parameters:
        left -
        right -
        Returns:
      • getBoolPMF

        public IProbabilityMassFunction getBoolPMF​(double trueProb)
        Converts a probability into a boolean PMF. The probability is taken as value for true and 1-probability as value for false.
        Parameters:
        left -
        right -
        Returns:
      • getProbabilityForValue

        public double getProbabilityForValue​(IProbabilityMassFunction iPMF,
                                             double valueToSeek)
        Retrieves the probability for a given value from a PMF.
        Parameters:
        iPMF -
        valueToSeek -
        Returns:
      • getThresholdProbability

        public double getThresholdProbability​(IProbabilityMassFunction iPMF,
                                              double threshold,
                                              boolean includeThreshold)
        Returns the sum of probabilities before a given value of a PMF.
        Parameters:
        iPMF -
        threshold -
        includeThreshold -
        Returns:
      • getComparePMF

        protected abstract IProbabilityMassFunction getComparePMF​(boolean left,
                                                                  boolean right)
        Compares two boolean values.
        Parameters:
        left -
        right -
        Returns:
      • getComparePMF

        protected abstract IProbabilityMassFunction getComparePMF​(double left,
                                                                  double right)
        Compares two doubles.
        Parameters:
        left -
        right -
        Returns:
      • invertBoolPMF

        public static IProbabilityMassFunction invertBoolPMF​(IProbabilityMassFunction function)
        This method inverts a BoolPMF as required by a NOT statement. This method would be better placed elsewhere, but it accesses internal knowledge how a BoolPMF is represented as a IProbabilityMassFunction which is only available in this class.
        Parameters:
        function -
        Returns:
        The inverted function, assuming this is a BoolPMF.
        Throws:
        UnsupportedOperationException - if the passed PMF is not a BoolPMF, i.e. if it does not contain the String literals "TRUE" and "FALSE".