Package aima.core.probability

Examples of aima.core.probability.RandomVariable


        b_kp2t.getFor());
    // Set up required working variables
    Proposition[] props = new Proposition[b_kp1t.getFor().size()];
    int i = 0;
    for (RandomVariable rv : b_kp1t.getFor()) {
      RandomVariable prv = tToTm1StateVarMap.get(rv);
      props[i] = new RandVar(prv.getName(), prv.getDomain());
      i++;
    }
    final Proposition Xk = ProbUtil.constructConjunction(props);
    final AssignmentProposition[] ax_kp1 = new AssignmentProposition[tToTm1StateVarMap
        .size()];
View Full Code Here


    // if EMPTY?(vars) then return 1.0
    if (0 == vars.size()) {
      return 1;
    }
    // Y <- FIRST(vars)
    RandomVariable Y = Util.first(vars);
    // if Y has value y in e
    if (e.containsValue(Y)) {
      // then return P(y | parents(Y)) * ENUMERATE-ALL(REST(vars), e)
      return e.posteriorForParents(Y) * enumerateAll(Util.rest(vars), e);
    }
    /**
     * <pre>
     *  else return &sum;<sub>y</sub> P(y | parents(Y)) * ENUMERATE-ALL(REST(vars), e<sub>y</sub>)
     *       where e<sub>y</sub> is e extended with Y = y
     * </pre>
     */
    double sum = 0;
    for (Object y : ((FiniteDomain) Y.getDomain()).getPossibleValues()) {
      e.setExtendedValue(Y, y);
      sum += e.posteriorForParents(Y) * enumerateAll(Util.rest(vars), e);
    }

    return sum;
View Full Code Here

      Set<RandomVariable> E_1, Node... rootNodes) {
    super(rootNodes);

    for (Map.Entry<RandomVariable, RandomVariable> x0_x1 : X_0_to_X_1
        .entrySet()) {
      RandomVariable x0 = x0_x1.getKey();
      RandomVariable x1 = x0_x1.getValue();
      this.X_0.add(x0);
      this.X_1.add(x1);
      this.X_0_to_X_1.put(x0, x1);
      this.X_1_to_X_0.put(x1, x0);
    }
View Full Code Here

  // START-Proposition
  public boolean holds(Map<RandomVariable, Object> possibleWorld) {
    boolean holds = true;

    Iterator<RandomVariable> i = getScope().iterator();
    RandomVariable rvC, rvL = i.next();
    while (i.hasNext()) {
      rvC = i.next();
      if (!possibleWorld.get(rvL).equals(possibleWorld.get(rvC))) {
        holds = false;
        break;
View Full Code Here

      return false;
    }

    // The name (not the name:domain combination) uniquely identifies a
    // Random Variable
    RandomVariable other = (RandomVariable) o;

    return this.name.equals(other.getName());
  }
View Full Code Here

    // if EMPTY?(vars) then return 1.0
    if (0 == vars.size()) {
      return 1;
    }
    // Y <- FIRST(vars)
    RandomVariable Y = Util.first(vars);
    // if Y has value y in e
    if (e.containsValue(Y)) {
      // then return P(y | parents(Y)) * ENUMERATE-ALL(REST(vars), e)
      return e.posteriorForParents(Y) * enumerateAll(Util.rest(vars), e);
    }
    /**
     * <pre>
     *  else return &sum;<sub>y</sub> P(y | parents(Y)) * ENUMERATE-ALL(REST(vars), e<sub>y</sub>)
     *       where e<sub>y</sub> is e extended with Y = y
     * </pre>
     */
    double sum = 0;
    for (Object y : ((FiniteDomain) Y.getDomain()).getPossibleValues()) {
      e.setExtendedValue(Y, y);
      sum += e.posteriorForParents(Y) * enumerateAll(Util.rest(vars), e);
    }

    return sum;
View Full Code Here

public class ProbabilityTableTest {
  public static final double DELTA_THRESHOLD = ProbabilityModel.DEFAULT_ROUNDING_THRESHOLD;

  @Test
  public void test_divideBy() {
    RandomVariable xRV = new RandVar("X", new BooleanDomain());
    RandomVariable yRV = new RandVar("Y", new BooleanDomain());
    RandomVariable zRV = new RandVar("Z", new BooleanDomain());

    ProbabilityTable xyzD = new ProbabilityTable(new double[] {
        // X = true, Y = true, Z = true
        1.0,
        // X = true, Y = true, Z = false
View Full Code Here

            .getValues(), DELTA_THRESHOLD);
  }

  @Test
  public void test_pointwiseProduct() {
    RandomVariable xRV = new RandVar("X", new BooleanDomain());
    RandomVariable yRV = new RandVar("Y", new BooleanDomain());
    RandomVariable zRV = new RandVar("Z", new BooleanDomain());

    ProbabilityTable xyD = new ProbabilityTable(new double[] {
        // X = true, Y = true
        1.0,
        // X = true, Y = false
View Full Code Here

        DELTA_THRESHOLD);
  }

  @Test
  public void test_pointwiseProductPOS() {
    RandomVariable xRV = new RandVar("X", new BooleanDomain());
    RandomVariable yRV = new RandVar("Y", new BooleanDomain());
    RandomVariable zRV = new RandVar("Z", new BooleanDomain());

    ProbabilityTable xyD = new ProbabilityTable(new double[] {
        // X = true, Y = true
        1.0,
        // X = true, Y = false
View Full Code Here

TOP

Related Classes of aima.core.probability.RandomVariable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.