/** * Constructor * * @param numSymbols the number of possible symbols (remember to include 0) * @param numCondSymbols the number of conditioning symbols * @param laplace if true, sub-estimators will use laplace */ public DDConditionalEstimator(int numSymbols, int numCondSymbols, boolean laplace) { m_Estimators = new DiscreteEstimator [numCondSymbols]; for(int i = 0; i < numCondSymbols; i++) { m_Estimators[i] = new DiscreteEstimator(numSymbols, laplace); } }
/** * Constructor * * @param numSymbols the number of possible symbols (remember to include 0) * @param numCondSymbols the number of conditioning symbols * @param laplace if true, sub-estimators will use laplace */ public DDConditionalEstimator(int numSymbols, int numCondSymbols, boolean laplace) { m_Estimators = new DiscreteEstimator [numCondSymbols]; for(int i = 0; i < numCondSymbols; i++) { m_Estimators[i] = new DiscreteEstimator(numSymbols, laplace); } }
/** * 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 DNConditionalEstimator(int numSymbols, double precision) { m_Estimators = new NormalEstimator [numSymbols]; for(int i = 0; i < numSymbols; i++) { m_Estimators[i] = new NormalEstimator(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 DNConditionalEstimator(int numSymbols, double precision) { m_Estimators = new NormalEstimator [numSymbols]; for(int i = 0; i < numSymbols; i++) { m_Estimators[i] = new NormalEstimator(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); }
DiscreteEstimator newEst = new DiscreteEstimator(max + 1, true);
DiscreteEstimator newEst = new DiscreteEstimator(max + 1, true);
DiscreteEstimator newEst = new DiscreteEstimator(max + 1, true);
DiscreteEstimator newEst = new DiscreteEstimator(max + 1, true);
DiscreteEstimator newEst = new DiscreteEstimator(max + 1, true); for (int i = 0; i < argv.length; i++) { current = Integer.parseInt(argv[i]);
DiscreteEstimator newEst = new DiscreteEstimator(max + 1, true); for (int i = 0; i < argv.length; i++) { current = Integer.parseInt(argv[i]);
/** * 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 DiscreteEstimator(m_Estimators.length,false); for(int i = 0; i < m_Estimators.length; i++) { result.addValue(i,m_Weights.getProbability(i) *m_Estimators[i].getProbability(given)); } 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 DiscreteEstimator(m_Estimators.length,false); for(int i = 0; i < m_Estimators.length; i++) { result.addValue(i,m_Weights.getProbability(i) *m_Estimators[i].getProbability(given)); } return result; }
protected static void testAggregation() { DiscreteEstimator df = new DiscreteEstimator(5, true); DiscreteEstimator one = new DiscreteEstimator(5, true); DiscreteEstimator two = new DiscreteEstimator(5, true); java.util.Random r = new java.util.Random(1); for (int i = 0; i < 100; i++) { int z = r.nextInt(5); df.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(df.toString()); System.out.println("Prob (0): " + df.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("\nAggregated\n"); System.out.println(one.toString()); System.out.println("Prob (0): " + one.getProbability(0)); } catch (Exception ex) { ex.printStackTrace(); } }
protected static void testAggregation() { DiscreteEstimator df = new DiscreteEstimator(5, true); DiscreteEstimator one = new DiscreteEstimator(5, true); DiscreteEstimator two = new DiscreteEstimator(5, true); java.util.Random r = new java.util.Random(1); for (int i = 0; i < 100; i++) { int z = r.nextInt(5); df.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(df.toString()); System.out.println("Prob (0): " + df.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("\nAggregated\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 DiscreteEstimator(m_Estimators.length,false); for(int i = 0; i < m_Estimators.length; i++) { //System.out.println("Val " + i // + " Weight:" + m_Weights.getProbability(i) // +" EstProb(" + given + ")=" // + m_Estimators[i].getProbability(given)); result.addValue(i, m_Weights.getProbability(i) * m_Estimators[i].getProbability(given)); } 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 DiscreteEstimator(m_Estimators.length,false); for(int i = 0; i < m_Estimators.length; i++) { //System.out.println("Val " + i // + " Weight:" + m_Weights.getProbability(i) // +" EstProb(" + given + ")=" // + m_Estimators[i].getProbability(given)); result.addValue(i, m_Weights.getProbability(i) * m_Estimators[i].getProbability(given)); } return result; }
/** * New probability estimators for an iteration */ private void new_estimators() { for (int i = 0; i < m_num_clusters; i++) { for (int j = 0; j < m_num_attribs; j++) { if (m_theInstances.attribute(j).isNominal()) { m_modelPrev[i][j] = m_model[i][j]; m_model[i][j] = new DiscreteEstimator(m_theInstances.attribute(j) .numValues(), true); } else { m_modelNormalPrev[i][j][0] = m_modelNormal[i][j][0]; m_modelNormalPrev[i][j][1] = m_modelNormal[i][j][1]; m_modelNormalPrev[i][j][2] = m_modelNormal[i][j][2]; m_modelNormal[i][j][0] = m_modelNormal[i][j][1] = m_modelNormal[i][j][2] = 0.0; } } } }
/** * New probability estimators for an iteration */ private void new_estimators() { for (int i = 0; i < m_num_clusters; i++) { for (int j = 0; j < m_num_attribs; j++) { if (m_theInstances.attribute(j).isNominal()) { m_modelPrev[i][j] = m_model[i][j]; m_model[i][j] = new DiscreteEstimator(m_theInstances.attribute(j) .numValues(), true); } else { m_modelNormalPrev[i][j][0] = m_modelNormal[i][j][0]; m_modelNormalPrev[i][j][1] = m_modelNormal[i][j][1]; m_modelNormalPrev[i][j][2] = m_modelNormal[i][j][2]; m_modelNormal[i][j][0] = m_modelNormal[i][j][1] = m_modelNormal[i][j][2] = 0.0; } } } }