Examples of FiniteDomain


Examples of aima.core.probability.domain.FiniteDomain

        if (!(rv.getDomain() instanceof FiniteDomain)) {
          throw new IllegalArgumentException(
              "Cannot have an infinite domain for a variable in this calculation:"
                  + rv);
        }
        FiniteDomain d = (FiniteDomain) rv.getDomain();
        expectedSizeOfDistribution *= d.size();
      }
    }

    return expectedSizeOfDistribution;
  }
View Full Code Here

Examples of aima.core.probability.domain.FiniteDomain

   *            Xi's distribution.
   * @return a Random Sample from Xi's domain.
   */
  public static Object sample(double probabilityChoice, RandomVariable Xi,
      double[] distribution) {
    FiniteDomain fd = (FiniteDomain) Xi.getDomain();
    if (fd.size() != distribution.length) {
      throw new IllegalArgumentException("Size of domain Xi " + fd.size()
          + " is not equal to the size of the distribution "
          + distribution.length);
    }
    int i = 0;
    double total = distribution[0];
    while (probabilityChoice > total) {
      i++;
      total += distribution[i];
    }
    return fd.getValueAt(i);
  }
View Full Code Here

Examples of aima.core.probability.domain.FiniteDomain

   *            comprising assignments for the Markov Blanket X<sub>i</sub>.
   * @return a random sample from <b>P</b>(X<sub>i</sub> | mb(X<sub>i</sub>))
   */
  public static double[] mbDistribution(Node Xi,
      Map<RandomVariable, Object> event) {
    FiniteDomain fd = (FiniteDomain) Xi.getRandomVariable().getDomain();
    double[] X = new double[fd.size()];

    for (int i = 0; i < fd.size(); i++) {
      // P(x'<sub>i</sub>|mb(Xi)) =
      // &alpha;P(x'<sub>i</sub>|parents(X<sub>i</sub>)) *
      // &prod;<sub>Y<sub>j</sub> &isin; Children(X<sub>i</sub>)</sub>
      // P(y<sub>j</sub>|parents(Y<sub>j</sub>))
      double cprob = 1.0;
      for (Node Yj : Xi.getChildren()) {
        cprob *= Yj.getCPD().getValue(
            getEventValuesForXiGivenParents(Yj, event));
      }
      X[i] = Xi.getCPD()
          .getValue(
              getEventValuesForXiGivenParents(Xi,
                  fd.getValueAt(i), event))
          * cprob;
    }

    return Util.normalize(X);
  }
View Full Code Here

Examples of aima.core.probability.domain.FiniteDomain

    // which corresponds with how displayed in book.
    int[] radixValues = new int[X.length];
    int[] radices = new int[X.length];
    int j = X.length - 1;
    for (int i = 0; i < X.length; i++) {
      FiniteDomain fd = (FiniteDomain) X[i].getDomain();
      radixValues[j] = fd.getOffset(x.get(X[i]));
      radices[j] = fd.size();
      j--;
    }

    return new MixedRadixNumber(radixValues, radices).intValue();
  }
View Full Code Here

Examples of aima.core.probability.domain.FiniteDomain

   */
  public static int[] indexesOfValue(RandomVariable[] X, int idx,
      Map<RandomVariable, Object> x) {
    int csize = ProbUtil.expectedSizeOfCategoricalDistribution(X);

    FiniteDomain fd = (FiniteDomain) X[idx].getDomain();
    int vdoffset = fd.getOffset(x.get(X[idx]));
    int vdosize = fd.size();
    int[] indexes = new int[csize / vdosize];

    int blocksize = csize;
    for (int i = 0; i < X.length; i++) {
      blocksize = blocksize / X[i].getDomain().size();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.