Exemplo n.º 1
0
  public MultivariatMean(
      Set<? extends Person> refPersons,
      Set<CachedPerson> simPersons,
      String xAttrKey,
      String yAttrKey,
      Discretizer xDataDiscr) {
    this.xDataKey = Converters.getObjectKey(xAttrKey);
    this.yDataKey = Converters.getObjectKey(yAttrKey);
    this.xDataDiscr = xDataDiscr;

    initReferenceValues(refPersons, xAttrKey, yAttrKey);
    initSimulationValues(simPersons, xAttrKey, yAttrKey);

    // Calculate the initial hamiltonian value.
    hamiltonianValue = 0;
    int size = Math.max(referenceValues.size(), bucketCounts.size());
    for (int i = 0; i < size; i++) {
      hamiltonianValue += calculateDiff(i);
    }
  }
Exemplo n.º 2
0
  @Override
  public void onChange(Object dataKey, Object oldValue, Object newValue, CachedElement person) {
    if (this.dataKey == null) this.dataKey = Converters.getObjectKey(attrKey);

    if (this.dataKey.equals(dataKey)) {
      int bucket = discretizer.index((Double) oldValue);
      double diff1 = changeBucketContent(bucket, -1);

      bucket = discretizer.index((Double) newValue);
      double diff2 = changeBucketContent(bucket, 1);

      hamiltonianValue += (diff1 + diff2) / normFactor;
    }
  }