weka.estimators
Class DiscreteEstimator

java.lang.Object
  extended byweka.estimators.DiscreteEstimator
All Implemented Interfaces:
Estimator, java.io.Serializable

public class DiscreteEstimator
extends java.lang.Object
implements Estimator

Simple symbolic probability estimator based on symbol counts.

Version:
$Revision: 1.5 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
private  double[] m_Counts
          Hold the counts
private  double m_SumOfCounts
          Hold the sum of counts
 
Constructor Summary
DiscreteEstimator(int numSymbols, boolean laplace)
          Constructor
DiscreteEstimator(int nSymbols, double fPrior)
          Constructor
 
Method Summary
 void addValue(double data, double weight)
          Add a new data value to the current estimator.
 int getNumSymbols()
          Gets the number of symbols this estimator operates with
 double getProbability(double data)
          Get a probability estimate for a value
static void main(java.lang.String[] argv)
          Main method for testing this class.
 java.lang.String toString()
          Display a representation of this estimator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Counts

private double[] m_Counts
Hold the counts


m_SumOfCounts

private double m_SumOfCounts
Hold the sum of counts

Constructor Detail

DiscreteEstimator

public DiscreteEstimator(int numSymbols,
                         boolean laplace)
Constructor

Parameters:
numSymbols - the number of possible symbols (remember to include 0)
laplace - if true, counts will be initialised to 1

DiscreteEstimator

public DiscreteEstimator(int nSymbols,
                         double fPrior)
Constructor

Parameters:
nSymbols - the number of possible symbols (remember to include 0)
fPrior - value with which counts will be initialised
Method Detail

addValue

public void addValue(double data,
                     double weight)
Add a new data value to the current estimator.

Specified by:
addValue in interface Estimator
Parameters:
data - the new data value
weight - the weight assigned to the data value

getProbability

public double getProbability(double data)
Get a probability estimate for a value

Specified by:
getProbability in interface Estimator
Parameters:
data - the value to estimate the probability of
Returns:
the estimated probability of the supplied value

getNumSymbols

public int getNumSymbols()
Gets the number of symbols this estimator operates with

Returns:
the number of estimator symbols

toString

public java.lang.String toString()
Display a representation of this estimator


main

public static void main(java.lang.String[] argv)
Main method for testing this class.

Parameters:
argv - should contain a sequence of integers which will be treated as symbolic.