LBJ2.learn
Class NaiveBayes.Count

java.lang.Object
  extended by LBJ2.learn.NaiveBayes.Count
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Enclosing class:
NaiveBayes

protected static class NaiveBayes.Count
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A Count object stores two doubles, one which holds a accumulated count value and the other intended to hold the natural logarithm of the count. The object also contains a boolean flag that is set when the log needs to be updated.

See Also:
Serialized Form

Field Summary
protected  double count
          The accumulated value.
protected  double logCount
          The natural logartihm of count is sometimes stored here.
protected  boolean updateLog
          A flag that is set iff logCount is not up to date.
 
Constructor Summary
NaiveBayes.Count()
          Sets the count to 0.
 
Method Summary
 java.lang.Object clone()
          This method returns a shallow clone.
 double getCount()
          Returns the integer count.
 double getLog()
          Returns the log after updating it.
 void increment(double inc)
          Increments the count, but does not update the log.
private  void readObject(java.io.ObjectInputStream in)
          Special handling during deserialization to ensure that updateLog is set to true.
 java.lang.String toString()
          The string representation of a Count object is simply the integer count.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

count

protected double count
The accumulated value.


logCount

protected transient double logCount
The natural logartihm of count is sometimes stored here.


updateLog

protected transient boolean updateLog
A flag that is set iff logCount is not up to date.

Constructor Detail

NaiveBayes.Count

public NaiveBayes.Count()
Sets the count to 0.

Method Detail

getCount

public double getCount()
Returns the integer count.


increment

public void increment(double inc)
Increments the count, but does not update the log.

Parameters:
inc - The amount the count should be incremented by.

getLog

public double getLog()
Returns the log after updating it.


toString

public java.lang.String toString()
The string representation of a Count object is simply the integer count.

Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
This method returns a shallow clone.

Overrides:
clone in class java.lang.Object
Returns:
A shallow clone.

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Special handling during deserialization to ensure that updateLog is set to true.

Parameters:
in - The stream to deserialize from.
Throws:
java.io.IOException
java.lang.ClassNotFoundException