List of usage examples for weka.core Statistics normalProbability
public static double normalProbability(double a)
From source file:moa.classifiers.core.driftdetection.STEPD.java
License:Open Source License
@Override public void input(double prediction) { // In MOA, 1.0=false, 0.0=true. if (!this.isInitialized) { initialize();/*from ww w .j ava2 s. c om*/ this.isInitialized = true; } else { if (this.isChangeDetected) { resetLearning(); } } if (nr == windowSize) { // Recent window is full. wo = wo + storedPredictions[firstPos]; // Oldest prediction in recent window no++; // is moved to older window, wr = wr - storedPredictions[firstPos]; firstPos++; // Start of recent window moves. if (firstPos == windowSize) { firstPos = 0; } } else { // Recent window grows. nr++; } lastPos++; // Adds prediction at the end of recent window. if (lastPos == windowSize) { lastPos = 0; } ; storedPredictions[lastPos] = (byte) prediction; wr += prediction; this.isWarningZone = false; if (no >= windowSize) { // The same as: (no + nr) >= 2 * windowSize. ro = no - wo; // Numbers of correct predictions are calculated. rr = nr - wr; sizeInvertedSum = 1.0 / no + 1.0 / nr; // Auxiliary variable. p = (ro + rr) / (no + nr); // Calculation of the statistics of STEPD. Z = Math.abs(ro / no - rr / nr); Z = Z - sizeInvertedSum / 2.0; Z = Z / Math.sqrt(p * (1.0 - p) * sizeInvertedSum); Z = Statistics.normalProbability(Math.abs(Z)); Z = 2 * (1 - Z); if (Z < alphaDrift) { // Drift Level this.isChangeDetected = true; } else { if (Z < alphaWarning) { // Warning Level this.isWarningZone = true; } } } }
From source file:tclass.util.FastMath.java
License:Open Source License
/** * Returns the normalCDF for the value; accurate to 10^-6 or so. *//*from ww w .j a va2 s. c o m*/ public static float normalCDF(float val) { if (val < min) { return (float) Statistics.normalProbability(val); } if (val > max) { return (float) Statistics.normalProbability(val); } else { //Find array position: float scaledVal = (val - min) / interval; int arrayIndex = (int) scaledVal; float remainder = scaledVal - arrayIndex; float lowerBnd = nCDFArray[arrayIndex]; float upperBnd = nCDFArray[arrayIndex + 1]; return (lowerBnd + (upperBnd - lowerBnd) * remainder); } }
From source file:tclass.util.FastMath.java
License:Open Source License
public static float logNormalCDF(float val) { if (val < min) { return (float) Math.log(Statistics.normalProbability(val)); }//from w w w . j a v a2 s. c o m if (val > max) { return (float) Math.log(Statistics.normalProbability(val)); } else { //Find array position: float scaledVal = (val - min) / interval; int arrayIndex = (int) scaledVal; float remainder = scaledVal - arrayIndex; float lowerBnd = nLCDFArray[arrayIndex]; float upperBnd = nLCDFArray[arrayIndex + 1]; return (lowerBnd + (upperBnd - lowerBnd) * remainder); } }
From source file:tclass.util.FastMath.java
License:Open Source License
public static void main(String args[]) { for (float i = -4.955f; i < 5.1; i += 0.1) { System.out.println("In: " + i + " N: " + normalCDF(i) + " LN: " + logNormalCDF(i) + " Ex: " + Statistics.normalProbability(i) + " Err: " + Math.abs(normalCDF(i) - Statistics.normalProbability(i))); }/*w ww . j ava 2 s. co m*/ float maxErr = 0; float maxErrPoint = 0; for (float i = -4.995f; i < 5.1; i += 0.01) { if (Math.abs(normalCDF(i) - Statistics.normalProbability(i)) > maxErr) { maxErr = (float) Math.abs(normalCDF(i) - Statistics.normalProbability(i)); maxErrPoint = i; } } System.err.println("Max Error Point = " + maxErrPoint + " Max Error = " + maxErr); }
From source file:tucil.Kernelatr.java
@Override public double getProbability(double data) { double delta, sum = 0, currentProb; double zLower, zUpper; if (numvalue == 0) { zLower = (data - (precision / 2)) / stdev; zUpper = (data + (precision / 2)) / stdev; return (Statistics.normalProbability(zUpper) - Statistics.normalProbability(zLower)); }//from w w w . ja v a 2s .c o m double weightSum = 0; int start = findNearestValue(data); for (int i = start; i < numvalue; i++) { delta = values[i] - data; zLower = (delta - (precision / 2)) / stdev; zUpper = (delta + (precision / 2)) / stdev; currentProb = (Statistics.normalProbability(zUpper) - Statistics.normalProbability(zLower)); sum += currentProb * weights[i]; weightSum += weights[i]; if (currentProb * (sumweight - weightSum) < sum * maxerror) { break; } } for (int i = start - 1; i >= 0; i--) { delta = values[i] - data; zLower = (delta - (precision / 2)) / stdev; zUpper = (delta + (precision / 2)) / stdev; currentProb = (Statistics.normalProbability(zUpper) - Statistics.normalProbability(zLower)); sum += currentProb * weights[i]; weightSum += weights[i]; if (currentProb * (sumweight - weightSum) < sum * maxerror) { break; } } return sum / sumweight; }
From source file:tucil.Normalatr.java
@Override public double getProbability(double data) { data = round(data);/*from w w w .j a v a 2 s . c o m*/ double zlower = (data - mean - (precision / 2)) / stdev; double zupper = (data - mean + (precision / 2)) / stdev; double plower = Statistics.normalProbability(zlower); double pupper = Statistics.normalProbability(zupper); return pupper - plower; }