/** * Constructor * * @param numCondSymbols the number of conditioning symbols * @param precision the precision to which numeric values are given. For * example, if the precision is stated to be 0.1, the values in the * interval (0.25,0.35] are all treated as 0.3. */ public KDConditionalEstimator(int numCondSymbols, double precision) { m_Estimators = new KernelEstimator [numCondSymbols]; for(int i = 0; i < numCondSymbols; i++) { m_Estimators[i] = new KernelEstimator(precision); } }
/** * Constructor * * @param numCondSymbols the number of conditioning symbols * @param precision the precision to which numeric values are given. For * example, if the precision is stated to be 0.1, the values in the * interval (0.25,0.35] are all treated as 0.3. */ public KDConditionalEstimator(int numCondSymbols, double precision) { m_Estimators = new KernelEstimator [numCondSymbols]; for(int i = 0; i < numCondSymbols; i++) { m_Estimators[i] = new KernelEstimator(precision); } }
/** * Constructor * * @param numSymbols the number of symbols * @param precision the precision to which numeric values are given. For * example, if the precision is stated to be 0.1, the values in the * interval (0.25,0.35] are all treated as 0.3. */ public DKConditionalEstimator(int numSymbols, double precision) { m_Estimators = new KernelEstimator [numSymbols]; for(int i = 0; i < numSymbols; i++) { m_Estimators[i] = new KernelEstimator(precision); } m_Weights = new DiscreteEstimator(numSymbols, true); }
/** * Constructor * * @param numSymbols the number of symbols * @param precision the precision to which numeric values are given. For * example, if the precision is stated to be 0.1, the values in the * interval (0.25,0.35] are all treated as 0.3. */ public DKConditionalEstimator(int numSymbols, double precision) { m_Estimators = new KernelEstimator [numSymbols]; for(int i = 0; i < numSymbols; i++) { m_Estimators[i] = new KernelEstimator(precision); } m_Weights = new DiscreteEstimator(numSymbols, true); }
return; KernelEstimator newEst = new KernelEstimator(0.01); for (int i = 0; i < argv.length - 3; i += 2) { newEst.addValue(Double.valueOf(argv[i]).doubleValue(),
return; KernelEstimator newEst = new KernelEstimator(0.01); for (int i = 0; i < argv.length - 3; i += 2) { newEst.addValue(Double.valueOf(argv[i]).doubleValue(),
public static void testAggregation() { KernelEstimator ke = new KernelEstimator(0.01); KernelEstimator one = new KernelEstimator(0.01); KernelEstimator two = new KernelEstimator(0.01); java.util.Random r = new java.util.Random(1); for (int i = 0; i < 100; i++) { double z = r.nextDouble(); ke.addValue(z, 1); if (i < 50) { one.addValue(z, 1); } else { two.addValue(z, 1); } } try { System.out.println("\n\nFull\n"); System.out.println(ke.toString()); System.out.println("Prob (0): " + ke.getProbability(0)); System.out.println("\nOne\n" + one.toString()); System.out.println("Prob (0): " + one.getProbability(0)); System.out.println("\nTwo\n" + two.toString()); System.out.println("Prob (0): " + two.getProbability(0)); one = one.aggregate(two); System.out.println("Aggregated\n"); System.out.println(one.toString()); System.out.println("Prob (0): " + one.getProbability(0)); } catch (Exception ex) { ex.printStackTrace(); } }
public static void testAggregation() { KernelEstimator ke = new KernelEstimator(0.01); KernelEstimator one = new KernelEstimator(0.01); KernelEstimator two = new KernelEstimator(0.01); java.util.Random r = new java.util.Random(1); for (int i = 0; i < 100; i++) { double z = r.nextDouble(); ke.addValue(z, 1); if (i < 50) { one.addValue(z, 1); } else { two.addValue(z, 1); } } try { System.out.println("\n\nFull\n"); System.out.println(ke.toString()); System.out.println("Prob (0): " + ke.getProbability(0)); System.out.println("\nOne\n" + one.toString()); System.out.println("Prob (0): " + one.getProbability(0)); System.out.println("\nTwo\n" + two.toString()); System.out.println("Prob (0): " + two.getProbability(0)); one = one.aggregate(two); System.out.println("Aggregated\n"); System.out.println(one.toString()); System.out.println("Prob (0): " + one.getProbability(0)); } catch (Exception ex) { ex.printStackTrace(); } }
/** * Get a probability estimator for a value * * @param given the new value that data is conditional upon * @return the estimator for the supplied value given the condition */ public Estimator getEstimator(double given) { Estimator result = new KernelEstimator(m_Precision); if (m_NumValues == 0) { return result; } double delta = 0, currentProb = 0; double zLower, zUpper; for(int i = 0; i < m_NumValues; i++) { delta = m_CondValues[i] - given; zLower = (delta - (m_Precision / 2)) / m_StandardDev; zUpper = (delta + (m_Precision / 2)) / m_StandardDev; currentProb = (Statistics.normalProbability(zUpper) - Statistics.normalProbability(zLower)); result.addValue(m_Values[i], currentProb * m_Weights[i]); } return result; }
/** * Get a probability estimator for a value * * @param given the new value that data is conditional upon * @return the estimator for the supplied value given the condition */ public Estimator getEstimator(double given) { Estimator result = new KernelEstimator(m_Precision); if (m_NumValues == 0) { return result; } double delta = 0, currentProb = 0; double zLower, zUpper; for(int i = 0; i < m_NumValues; i++) { delta = m_CondValues[i] - given; zLower = (delta - (m_Precision / 2)) / m_StandardDev; zUpper = (delta + (m_Precision / 2)) / m_StandardDev; currentProb = (Statistics.normalProbability(zUpper) - Statistics.normalProbability(zLower)); result.addValue(m_Values[i], currentProb * m_Weights[i]); } return result; }
case Attribute.NUMERIC: if (m_UseKernelEstimator) { m_Distributions[attIndex][j] = new KernelEstimator(numPrecision); } else { m_Distributions[attIndex][j] = new NormalEstimator(numPrecision);
case Attribute.NUMERIC: if (m_UseKernelEstimator) { m_Distributions[attIndex][j] = new KernelEstimator(numPrecision); } else { m_Distributions[attIndex][j] = new NormalEstimator(numPrecision);