コード例 #1
0
        public CategoricalDistribution posteriorDistribution(IProposition phi,
                                                             params IProposition[] evidence)
        {
            IProposition conjEvidence = ProbUtil.constructConjunction(evidence);

            // P(A | B) = P(A AND B)/P(B) - (13.3 AIMA3e)
            CategoricalDistribution dAandB    = jointDistribution(phi, conjEvidence);
            CategoricalDistribution dEvidence = jointDistribution(conjEvidence);

            return(dAandB.divideBy(dEvidence));
        }
コード例 #2
0
 public CategoricalDistributionIteratorAdapter(
     CategoricalDistribution.Iterator cdi)
 {
     this.cdi = cdi;
 }
コード例 #3
0
 public void iterateOver(CategoricalDistribution.Iterator cdi,
                         params AssignmentProposition[] fixedValues)
 {
     iterateOverTable(new CategoricalDistributionIteratorAdapter(cdi),
                      fixedValues);
 }
コード例 #4
0
 public override void iterateOver(CategoricalDistribution.Iterator cdi)
 {
     iterateOverTable(new CategoricalDistributionIteratorAdapter(cdi));
 }
コード例 #5
0
 public override CategoricalDistribution multiplyByPOS(
     CategoricalDistribution multiplier, params RandomVariable[] prodVarOrder)
 {
     return pointwiseProductPOS((ProbabilityTable) multiplier, prodVarOrder);
 }
コード例 #6
0
 public override CategoricalDistribution multiplyBy(CategoricalDistribution multiplier)
 {
     return pointwiseProduct((ProbabilityTable) multiplier);
 }
コード例 #7
0
 public override CategoricalDistribution divideBy(CategoricalDistribution divisor)
 {
     return divideBy((ProbabilityTable) divisor);
 }
コード例 #8
0
        /**
         * Multiplication - Product Order Specified (POS). <b>Note:</b> Is
         * equivalent to pointwise product calculation.<br>
         * <br>
         * see: AIMA3e Figure 14.10 page 527.<br>
         * <br>
         * Multiplication of this Distribution by a given multiplier, creating a new
         * Distribution representing the product of the two. The order of the
         * variables comprising the product will match those specified. For example
         * (the General case of Baye's rule, AIMA3e pg. 496), using this API method:<br>
         * <br>
         * <b>P</b>(Y | X) = (<b>P</b>(X | Y)<b>P</b>(Y), [Y, X])/<b>P</b>(X)<br>
         * <br>
         * is true when the correct product order is specified.
         * 
         * @param multiplier
         * @param prodVarOrder
         *            the order the variables comprising the product are to be in.
         * 
         * @return a new Distribution representing the product of this and the
         *         passed in multiplier. The order of the variables comprising the
         *         product distribution is the order specified.
         * 
         * @see CategoricalDistribution#multiplyBy(CategoricalDistribution)
         */

        public abstract CategoricalDistribution multiplyByPOS(CategoricalDistribution multiplier,
                                              params RandomVariable[] prodVarOrder);
コード例 #9
0
 /**
  * Multiplication of this Distribution by a given multiplier, creating a new
  * Distribution representing the product of the two. <b>Note:</b> Is
  * equivalent to pointwise product calculation on factors.<br>
  * <br>
  * see: AIMA3e Figure 14.10 page 527.<br>
  * <br>
  * Note: Default Distribution multiplication is not commutative. The reason
  * is because the order of the variables comprising a Distribution dictate
  * the ordering of the values for that distribution. For example (the
  * General case of Baye's rule, AIMA3e pg. 496), using this API method:<br>
  * <br>
  * <b>P</b>(Y | X) = (<b>P</b>(X | Y)<b>P</b>(Y))/<b>P</b>(X)<br>
  * <br>
  * is NOT true, due to multiplication of distributions not being
  * commutative. However:<br>
  * <br>
  * <b>P</b>(Y | X) = (<b>P</b>(Y)<b>P</b>(X | Y))/<b>P</b>(X)<br>
  * <br>
  * is true, using this API.<br>
  * <br>
  * The default order of the variable of the Distribution returned is the
  * order of the variables as they are seen, as read from the left to right
  * term, for e.g.: <br>
  * <br>
  * <b>P</b>(Y)<b>P</b>(X | Y)<br>
  * <br>
  * would give a Distribution of the following form: <br>
  * Y, X<br>
  * <br>
  * i.e. an ordered union of the variables from the two distributions. <br>
  * To override the default order of the product use multiplyByPOS().
  * 
  * @param multiplier
  * 
  * @return a new Distribution representing the product of this and the
  *         passed in multiplier. The order of the variables comprising the
  *         product distribution is the ordered union of the left term (this)
  *         and the right term (multiplier).
  * 
  * @see CategoricalDistribution#multiplyByPOS(CategoricalDistribution,
  *      params RandomVariable [])
  */
 public abstract CategoricalDistribution multiplyBy(CategoricalDistribution multiplier);
コード例 #10
0
 /**
  * Divide the dividend (this) CategoricalDistribution by the divisor to
  * create a new CategoricalDistribution representing the quotient. The
  * variables comprising the divisor distribution must be a subset of the
  * dividend. However, ordering of variables does not matter as the quotient
  * contains the same variables as the dividend and the internal
  * implementation logic should handle iterating through the two
  * distributions correctly, irrespective of the order of their variables.
  * 
  * @param divisor
  * @return a new Distribution representing the quotient of the dividend
  *         (this) divided by the divisor.
  * @throws IllegalArgumentException
  *             if the variables of the divisor distribution are not a subset
  *             of the dividend.
  */
 public abstract CategoricalDistribution divideBy(CategoricalDistribution divisor);
コード例 #11
0
        /**
         * Multiplication - Product Order Specified (POS). <b>Note:</b> Is
         * equivalent to pointwise product calculation.<br>
         * <br>
         * see: AIMA3e Figure 14.10 page 527.<br>
         * <br>
         * Multiplication of this Distribution by a given multiplier, creating a new
         * Distribution representing the product of the two. The order of the
         * variables comprising the product will match those specified. For example
         * (the General case of Baye's rule, AIMA3e pg. 496), using this API method:<br>
         * <br>
         * <b>P</b>(Y | X) = (<b>P</b>(X | Y)<b>P</b>(Y), [Y, X])/<b>P</b>(X)<br>
         * <br>
         * is true when the correct product order is specified.
         *
         * @param multiplier
         * @param prodVarOrder
         *            the order the variables comprising the product are to be in.
         *
         * @return a new Distribution representing the product of this and the
         *         passed in multiplier. The order of the variables comprising the
         *         product distribution is the order specified.
         *
         * @see CategoricalDistribution#multiplyBy(CategoricalDistribution)
         */

        public abstract CategoricalDistribution multiplyByPOS(CategoricalDistribution multiplier,
                                                              params RandomVariable[] prodVarOrder);
コード例 #12
0
 /**
  * Multiplication of this Distribution by a given multiplier, creating a new
  * Distribution representing the product of the two. <b>Note:</b> Is
  * equivalent to pointwise product calculation on factors.<br>
  * <br>
  * see: AIMA3e Figure 14.10 page 527.<br>
  * <br>
  * Note: Default Distribution multiplication is not commutative. The reason
  * is because the order of the variables comprising a Distribution dictate
  * the ordering of the values for that distribution. For example (the
  * General case of Baye's rule, AIMA3e pg. 496), using this API method:<br>
  * <br>
  * <b>P</b>(Y | X) = (<b>P</b>(X | Y)<b>P</b>(Y))/<b>P</b>(X)<br>
  * <br>
  * is NOT true, due to multiplication of distributions not being
  * commutative. However:<br>
  * <br>
  * <b>P</b>(Y | X) = (<b>P</b>(Y)<b>P</b>(X | Y))/<b>P</b>(X)<br>
  * <br>
  * is true, using this API.<br>
  * <br>
  * The default order of the variable of the Distribution returned is the
  * order of the variables as they are seen, as read from the left to right
  * term, for e.g.: <br>
  * <br>
  * <b>P</b>(Y)<b>P</b>(X | Y)<br>
  * <br>
  * would give a Distribution of the following form: <br>
  * Y, X<br>
  * <br>
  * i.e. an ordered union of the variables from the two distributions. <br>
  * To override the default order of the product use multiplyByPOS().
  *
  * @param multiplier
  *
  * @return a new Distribution representing the product of this and the
  *         passed in multiplier. The order of the variables comprising the
  *         product distribution is the ordered union of the left term (this)
  *         and the right term (multiplier).
  *
  * @see CategoricalDistribution#multiplyByPOS(CategoricalDistribution,
  *      params RandomVariable [])
  */
 public abstract CategoricalDistribution multiplyBy(CategoricalDistribution multiplier);
コード例 #13
0
 /**
  * Divide the dividend (this) CategoricalDistribution by the divisor to
  * create a new CategoricalDistribution representing the quotient. The
  * variables comprising the divisor distribution must be a subset of the
  * dividend. However, ordering of variables does not matter as the quotient
  * contains the same variables as the dividend and the internal
  * implementation logic should handle iterating through the two
  * distributions correctly, irrespective of the order of their variables.
  *
  * @param divisor
  * @return a new Distribution representing the quotient of the dividend
  *         (this) divided by the divisor.
  * @throws IllegalArgumentException
  *             if the variables of the divisor distribution are not a subset
  *             of the dividend.
  */
 public abstract CategoricalDistribution divideBy(CategoricalDistribution divisor);