package am.app.mappingEngine.qualityEvaluation.metrics.ufl;

import java.util.List;

import am.app.mappingEngine.AbstractMatcher.alignType;
import am.app.mappingEngine.qualityEvaluation.AbstractQualityMetric;
import am.app.mappingEngine.similarityMatrix.SimilarityMatrix;
import static am.evaluation.disagreement.variance.VarianceComputation.computeVariance;

/**
 * Compute the disagreement between matching algorithms given their individual
 * similarity matrices. The constructor takes only one kind of matrix, either
 * the classes matrices or the properties matrices. You must instantiate a
 * separate object for each type of matrices.
 * 
 * @author <a href="http://cstroe.com">Cosmin Stroe</a>
 * 
 */
public class VarianceMatcherDisagreement extends AbstractQualityMetric {

	private SimilarityMatrix[] matrices;
	
	public VarianceMatcherDisagreement(List<SimilarityMatrix> matrices) {
		super();
		this.matrices = matrices.toArray(new SimilarityMatrix[0]);
	}
	
	/**
	 * @param type
	 *            This parameter is ignored.
	 */
	@Override
	public double getQuality(alignType type, int i, int j) {
		// create signature vector
		double[] signatureVector = new double[matrices.length];
		for(int k = 0; k < matrices.length; k++) {
			signatureVector[k] = matrices[k].getSimilarity(i, j);
		}
		
		// return the computed variance
		return computeVariance(signatureVector);
	}
}

@@ -1336,16 +1336,136 @@
 nce%0A
+%09%09// because variance of similarity values can be a maximum of 0.5, we%0A%09%09// multiply by 2 to get a metric from 0 to 1.0%0A
 %09%09return
  com
@@ -1460,16 +1460,20 @@
 %09%09return
+ 2 *
  compute

Normalize the variance to 1.0 (from 0.5)