ostore.introspect
Class WeightedAvgFilter

java.lang.Object
  |
  +--ostore.introspect.WeightedAvgFilter
All Implemented Interfaces:
QuickSerializable, SemanticDistanceModel.Filter

public class WeightedAvgFilter
extends Object
implements SemanticDistanceModel.Filter

Simple filter that calculates the new semantic distance based on the weighted geometric average: (w*old + (1-w)*new^2)/2, where w is the ratio t.num/(t.num + t2.num).

The realtime distance can be approximated with sqrt(d).

Version:
$Id: WeightedAvgFilter.java,v 1.4 2003/04/03 01:10:22 jeffpang Exp $
Author:
Jeff Pang

Constructor Summary
WeightedAvgFilter()
          Create a new WeightedAvgFilter where nothing is considered to be an outlier (unless at distance INFINITY).
WeightedAvgFilter(Distance outlier)
          Create a new WeightedAvgFilter where certain observations are considered outliers.
WeightedAvgFilter(InputBuffer buffer)
           
 
Method Summary
 Distance getOutlier()
          Get the outlier value.
 Distance recalculate(Distance previous_age, Distance increment)
          Update the age of the model as a function of the previous_age value and the increment amount of time since the last call to this function.
 void recalculate(SemanticDistanceModel.Tuple current, Distance age, Distance val)
          Recalcualate the semantic distance and weight of a tuple given the tuple's contents (distance and previous weight) the new observed value.
 void recalculate(SemanticDistanceModel.Tuple current, Distance age, Set vals)
          Recalculate the semantic distance given the old distance and the new observed values (in order).
 void serialize(OutputBuffer buffer)
          Add the object to the buffer.
 void setOutlier(Distance outlier)
          Set the outlier value.
 Distance sum(Distance current_age, Distance addum_age)
          Update the age of the model as a function of the current_age of this model and the addum_age of the table we are incorporating into this model.
 void sum(SemanticDistanceModel.Tuple current, Distance curr_age, int curr_clients, SemanticDistanceModel.Tuple addum, Distance addum_age, int addum_clients)
          Recalculate the semantic distance and weight of a tuple given a new distance value from another semantic distance table.
 String toString()
           
 void update_priority(SemanticDistanceModel.Tuple t, SemanticDistanceModel.BoundedPrioQueue q)
          Recalcualte the priority of t.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeightedAvgFilter

public WeightedAvgFilter()
Create a new WeightedAvgFilter where nothing is considered to be an outlier (unless at distance INFINITY).


WeightedAvgFilter

public WeightedAvgFilter(Distance outlier)
Create a new WeightedAvgFilter where certain observations are considered outliers.

Parameters:
outlier - any observation at distance >= this is considered to be an outlier and is ignored.

WeightedAvgFilter

public WeightedAvgFilter(InputBuffer buffer)
                  throws QSException
Method Detail

serialize

public void serialize(OutputBuffer buffer)
Description copied from interface: QuickSerializable
Add the object to the buffer.

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to

recalculate

public void recalculate(SemanticDistanceModel.Tuple current,
                        Distance age,
                        Distance val)
Description copied from interface: SemanticDistanceModel.Filter
Recalcualate the semantic distance and weight of a tuple given the tuple's contents (distance and previous weight) the new observed value. This method should filter out any new val that is considered an outlier (i.e., in that case it should just return old so the value does not change.

Specified by:
recalculate in interface SemanticDistanceModel.Filter
Parameters:
current - the tuple to be updated (contains the current semantic distance)
age - the age of the current model
val - the new value recorded

recalculate

public void recalculate(SemanticDistanceModel.Tuple current,
                        Distance age,
                        Set vals)
Description copied from interface: SemanticDistanceModel.Filter
Recalculate the semantic distance given the old distance and the new observed values (in order).

Specified by:
recalculate in interface SemanticDistanceModel.Filter
Parameters:
current - the old semantic distance
age - the age of the current model
vals - the new Set<Distance> values recorded

recalculate

public Distance recalculate(Distance previous_age,
                            Distance increment)
Description copied from interface: SemanticDistanceModel.Filter
Update the age of the model as a function of the previous_age value and the increment amount of time since the last call to this function.

This is usually only called each time we receive a new observation.

Specified by:
recalculate in interface SemanticDistanceModel.Filter
Parameters:
previous_age - the previous age value
increment - the amount of time since the previous call to this function
Returns:
the new age value for this model

sum

public void sum(SemanticDistanceModel.Tuple current,
                Distance curr_age,
                int curr_clients,
                SemanticDistanceModel.Tuple addum,
                Distance addum_age,
                int addum_clients)
Description copied from interface: SemanticDistanceModel.Filter
Recalculate the semantic distance and weight of a tuple given a new distance value from another semantic distance table.

Specified by:
sum in interface SemanticDistanceModel.Filter
Parameters:
current - the tuple to be updated
curr_age - the age of the current model
curr_clients - the number of clients represented by the current model
addum - the new tuple from the other table
addum_age - the age of the other model
addum_clients - the number of clients represented by the other model

sum

public Distance sum(Distance current_age,
                    Distance addum_age)
Description copied from interface: SemanticDistanceModel.Filter
Update the age of the model as a function of the current_age of this model and the addum_age of the table we are incorporating into this model.

Specified by:
sum in interface SemanticDistanceModel.Filter

update_priority

public void update_priority(SemanticDistanceModel.Tuple t,
                            SemanticDistanceModel.BoundedPrioQueue q)
Description copied from interface: SemanticDistanceModel.Filter
Recalcualte the priority of t. This is used to determine its position in the table's prio queue. Smaller values are more likely to be kept than larger values.

Specified by:
update_priority in interface SemanticDistanceModel.Filter
Parameters:
t - the tuple
q - the prio queue this tuple is to be placed in or is already in. WARNING: if t is already in the queue, then its priority is not yet updated. The queue may not be in order.
Returns:
the priority of t as a distance.

setOutlier

public void setOutlier(Distance outlier)
Set the outlier value. Any distance >= this is considered an outlier and is ignored.


getOutlier

public Distance getOutlier()
Get the outlier value.


toString

public String toString()
Overrides:
toString in class Object