weka.estimators
Class NNConditionalEstimator

java.lang.Object
  extended byweka.estimators.NNConditionalEstimator
All Implemented Interfaces:
ConditionalEstimator

public class NNConditionalEstimator
extends java.lang.Object
implements ConditionalEstimator

Conditional probability estimator for a numeric domain conditional upon a numeric domain (using Mahalanobis distance).

Version:
$Revision: 1.4 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz)

Field Summary
private  boolean m_AllWeightsOne
          Whether we can optimise the kernel summation
private  double m_CondMean
          Current Conditional mean
private  java.util.Vector m_CondValues
          Vector containing all of the conditioning values seen
private  Matrix m_Covariance
          Current covariance matrix
private  double m_SumOfWeights
          The sum of the weights so far
private  double m_ValueMean
          Current Values mean
private  java.util.Vector m_Values
          Vector containing all of the values seen
private  java.util.Vector m_Weights
          Vector containing the associated weights
private static double TWO_PI
          2 * PI
 
Constructor Summary
NNConditionalEstimator()
           
 
Method Summary
 void addValue(double data, double given, double weight)
          Add a new data value to the current estimator.
private  void calculateCovariance()
          Calculate covariance and value means
private  int findNearestPair(double key, double secondaryKey)
          Execute a binary search to locate the nearest data value
 Estimator getEstimator(double given)
          Get a probability estimator for a value
 double getProbability(double data, double given)
          Get a probability estimate for a value
static void main(java.lang.String[] argv)
          Main method for testing this class.
private  double normalKernel(double x, double variance)
          Returns value for normal kernel
 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_Values

private java.util.Vector m_Values
Vector containing all of the values seen


m_CondValues

private java.util.Vector m_CondValues
Vector containing all of the conditioning values seen


m_Weights

private java.util.Vector m_Weights
Vector containing the associated weights


m_SumOfWeights

private double m_SumOfWeights
The sum of the weights so far


m_CondMean

private double m_CondMean
Current Conditional mean


m_ValueMean

private double m_ValueMean
Current Values mean


m_Covariance

private Matrix m_Covariance
Current covariance matrix


m_AllWeightsOne

private boolean m_AllWeightsOne
Whether we can optimise the kernel summation


TWO_PI

private static double TWO_PI
2 * PI

Constructor Detail

NNConditionalEstimator

public NNConditionalEstimator()
Method Detail

findNearestPair

private int findNearestPair(double key,
                            double secondaryKey)
Execute a binary search to locate the nearest data value

Parameters:
key - the data value to locate
secondaryKey - the data value to locate
Returns:
the index of the nearest data value

calculateCovariance

private void calculateCovariance()
Calculate covariance and value means


normalKernel

private double normalKernel(double x,
                            double variance)
Returns value for normal kernel

Parameters:
x - the argument to the kernel function
variance - the variance
Returns:
the value for a normal kernel

addValue

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

Specified by:
addValue in interface ConditionalEstimator
Parameters:
data - the new data value
given - the new value that data is conditional upon
weight - the weight assigned to the data value

getEstimator

public Estimator getEstimator(double given)
Get a probability estimator for a value

Specified by:
getEstimator in interface ConditionalEstimator
Parameters:
given - the new value that data is conditional upon
Returns:
the estimator for the supplied value given the condition

getProbability

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

Specified by:
getProbability in interface ConditionalEstimator
Parameters:
data - the value to estimate the probability of
given - the new value that data is conditional upon
Returns:
the estimated probability of the supplied value

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 numeric values