List of usage examples for org.apache.commons.math.distribution NormalDistributionImpl density
@Override public double density(double x)
From source file:org.dutir.lucene.util.Distance.java
/** * /*from w ww . j a va2 s. c o m*/ * @param positionOfTerm1 * @param positionOfTerm2 * @return */ public static double unorderGaussianTimes(final int[] positionOfTerm1, final int[] positionOfTerm2, NormalDistributionImpl nDist) { double retValue = 0; if (positionOfTerm1 == null || positionOfTerm2 == null) { return 0; } for (int i = 0; i < positionOfTerm1.length; i++) { for (int j = 0; j < positionOfTerm2.length; j++) { double dist = nDist.density(Math.abs(positionOfTerm1[i] - positionOfTerm2[j])); if (dist > 0) { retValue += dist; } } } return retValue; }
From source file:org.dutir.lucene.util.Distance.java
/** * //w w w . j a va 2 s .co m * @param positionOfTerm1 * @param positionOfTerm2 * @param winSize can exceed the size the the documents * @return */ public static double unorderGaussianTimes(final int[] positionOfTerm1, final int[] positionOfTerm2, final int winSize, NormalDistributionImpl nDist) { double retValue = 0; if (positionOfTerm1 == null || positionOfTerm2 == null) { return 0; } for (int i = 0; i < positionOfTerm1.length; i++) { for (int j = 0; j < positionOfTerm2.length; j++) { double tmp = Math.abs(positionOfTerm1[i] - positionOfTerm2[j]); double dist = nDist.density(tmp); if (dist > 0 && tmp < winSize) { retValue += dist; } else { // System.out.println(tmp +":" + dist); } } } return retValue; }