Ejemplo n.º 1
0
  public UnivariatFrequency(
      Set<? extends Attributable> refElements,
      Set<? extends Attributable> simElements,
      String attrKey,
      Discretizer discretizer) {
    this.discretizer = discretizer;
    this.attrKey = attrKey;

    refFreq = initHistogram(refElements, attrKey);
    simFreq = initHistogram(simElements, attrKey);

    scaleFactor = simElements.size() / (double) refElements.size();
    normFactor = 1; // simElements.size();

    int size = Math.max(simFreq.size(), refFreq.size());
    for (int i = 0; i < size; i++) {
      double simVal = simFreq.get(i);
      double refVal = refFreq.get(i) * scaleFactor;

      //            hamiltonianValue += (Math.abs(simVal - refVal)/ refVal)/normFactor;
      hamiltonianValue += calculateError(simVal, refVal) / normFactor;
    }
  }
Ejemplo n.º 2
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);
    }
  }