Estimator.java
Upload User: rhdiban
Upload Date: 2013-08-09
Package Size: 15085k
Code Size: 2k
Category:

Windows Develop

Development Platform:

Java

  1. /*
  2.  *    This program is free software; you can redistribute it and/or modify
  3.  *    it under the terms of the GNU General Public License as published by
  4.  *    the Free Software Foundation; either version 2 of the License, or
  5.  *    (at your option) any later version.
  6.  *
  7.  *    This program is distributed in the hope that it will be useful,
  8.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.  *    GNU General Public License for more details.
  11.  *
  12.  *    You should have received a copy of the GNU General Public License
  13.  *    along with this program; if not, write to the Free Software
  14.  *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15.  */
  16. /*
  17.  *    Estimator.java
  18.  *    Copyright (C) 1999 Len Trigg
  19.  *
  20.  */
  21. package weka.estimators;
  22. import java.util.*;
  23. import java.io.*;
  24. /** 
  25.  * Interface for probability estimators. Example code: <p>
  26.  *
  27.  * <code> <pre>
  28.  *   // Create a discrete estimator that takes values 0 to 9
  29.  *   DiscreteEstimator newEst = new DiscreteEstimator(10, true);
  30.  *
  31.  *   // Create 50 random integers first predicting the probability of the
  32.  *   // value, then adding the value to the estimator
  33.  *   Random r = new Random(seed);
  34.  *   for(int i = 0; i < 50; i++) {
  35.  *     current = Math.abs(r.nextInt() % 10);
  36.  *     System.out.println(newEst);
  37.  *     System.out.println("Prediction for " + current 
  38.  *                        + " = " + newEst.getProbability(current));
  39.  *     newEst.addValue(current, 1);
  40.  *   }
  41.  * </pre> </code>
  42.  *
  43.  * @author Len Trigg (trigg@cs.waikato.ac.nz)
  44.  * @version $Revision: 1.4 $
  45.  */
  46. public interface Estimator extends Serializable {
  47.   /**
  48.    * Add a new data value to the current estimator.
  49.    *
  50.    * @param data the new data value 
  51.    * @param weight the weight assigned to the data value 
  52.    */
  53.   public void addValue(double data, double weight);
  54.   /**
  55.    * Get a probability estimate for a value.
  56.    *
  57.    * @param data the value to estimate the probability of
  58.    * @return the estimated probability of the supplied value
  59.    */
  60.   public double getProbability(double data);
  61. }