Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance
Class PreferenceVectorBasedCorrelationDistance

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.AbstractDistance<D>
      extended by de.lmu.ifi.dbs.elki.distance.CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
          extended by de.lmu.ifi.dbs.elki.distance.PreferenceVectorBasedCorrelationDistance
All Implemented Interfaces:
Distance<PreferenceVectorBasedCorrelationDistance>, Externalizable, Serializable, Comparable<PreferenceVectorBasedCorrelationDistance>

public class PreferenceVectorBasedCorrelationDistance
extends CorrelationDistance<PreferenceVectorBasedCorrelationDistance>

A PreferenceVectorBasedCorrelationDistance holds additionally to the CorrelationDistance the common preference vector of the two objects defining the distance.

Author:
Elke Achtert
See Also:
Serialized Form

Field Summary
private  BitSet commonPreferenceVector
          The common preference vector of the two objects defining this distance.
private  int dimensionality
          The dimensionality of the feature space (needed for serialization).
private static long serialVersionUID
           
 
Constructor Summary
PreferenceVectorBasedCorrelationDistance()
          Empty constructor for serialization purposes.
PreferenceVectorBasedCorrelationDistance(int dimensionality, int correlationValue, double euclideanValue, BitSet commonPreferenceVector)
          Constructs a new CorrelationDistance object.
 
Method Summary
 int compareTo(PreferenceVectorBasedCorrelationDistance distance)
          Checks if the dimensionality values of this distance and the specified distance are equal.
 String description()
          Returns a String as description of this Distance.
 int externalizableSize()
          Returns the number of Bytes this distance uses if it is written to an external file.
 BitSet getCommonPreferenceVector()
          Returns the common preference vector of the two objects defining this distance.
 PreferenceVectorBasedCorrelationDistance minus(PreferenceVectorBasedCorrelationDistance distance)
          Returns a new Distance by subtracting the given distance from this distance.
 PreferenceVectorBasedCorrelationDistance plus(PreferenceVectorBasedCorrelationDistance distance)
          Returns a new distance as sum of this distance and the given distance.
 void readExternal(ObjectInput in)
          Calls CorrelationDistance.readExternal(java.io.ObjectInput) and reads additionally the dimensionality and each Byte of the common preference vector from the specified stream..
 String toString()
          Returns a string representation of this PreferenceVectorBasedCorrelationDistance.
 void writeExternal(ObjectOutput out)
          Calls CorrelationDistance.writeExternal(java.io.ObjectOutput) and writes additionally the dimensionality and each Byte of the common preference vector to the specified stream.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.CorrelationDistance
getCorrelationValue, getEuclideanValue, hashCode
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractDistance
equals
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

dimensionality

private int dimensionality
The dimensionality of the feature space (needed for serialization).


commonPreferenceVector

private BitSet commonPreferenceVector
The common preference vector of the two objects defining this distance.

Constructor Detail

PreferenceVectorBasedCorrelationDistance

public PreferenceVectorBasedCorrelationDistance()
Empty constructor for serialization purposes.


PreferenceVectorBasedCorrelationDistance

public PreferenceVectorBasedCorrelationDistance(int dimensionality,
                                                int correlationValue,
                                                double euclideanValue,
                                                BitSet commonPreferenceVector)
Constructs a new CorrelationDistance object.

Parameters:
dimensionality - the dimensionality of the feature space (needed for serialization)
correlationValue - the correlation dimension to be represented by the CorrelationDistance
euclideanValue - the euclidean distance to be represented by the CorrelationDistance
commonPreferenceVector - the common preference vector of the two objects defining this distance
Method Detail

getCommonPreferenceVector

public BitSet getCommonPreferenceVector()
Returns the common preference vector of the two objects defining this distance.

Returns:
the common preference vector

description

public String description()
Description copied from interface: Distance
Returns a String as description of this Distance.

Specified by:
description in interface Distance<PreferenceVectorBasedCorrelationDistance>
Overrides:
description in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Returns:
a String as description of this Distance

toString

public String toString()
Returns a string representation of this PreferenceVectorBasedCorrelationDistance.

Specified by:
toString in interface Distance<PreferenceVectorBasedCorrelationDistance>
Overrides:
toString in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Returns:
the correlation value, the euclidean value and the common preference vector separated by blanks

plus

public PreferenceVectorBasedCorrelationDistance plus(PreferenceVectorBasedCorrelationDistance distance)
Description copied from interface: Distance
Returns a new distance as sum of this distance and the given distance.

Specified by:
plus in interface Distance<PreferenceVectorBasedCorrelationDistance>
Overrides:
plus in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Parameters:
distance - the distance to be added to this distance
Returns:
a new distance as sum of this distance and the given distance
Throws:
IllegalArgumentException - if the dimensionality values and common preference vectors of this distance and the specified distance are not equal

minus

public PreferenceVectorBasedCorrelationDistance minus(PreferenceVectorBasedCorrelationDistance distance)
Description copied from interface: Distance
Returns a new Distance by subtracting the given distance from this distance.

Specified by:
minus in interface Distance<PreferenceVectorBasedCorrelationDistance>
Overrides:
minus in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Parameters:
distance - the distance to be subtracted from this distance
Returns:
a new Distance by subtracting the given distance from this distance
Throws:
IllegalArgumentException - if the dimensionality values and common preference vectors of this distance and the specified distance are not equal

compareTo

public int compareTo(PreferenceVectorBasedCorrelationDistance distance)
Checks if the dimensionality values of this distance and the specified distance are equal. If the check fails an IllegalArgumentException is thrown, otherwise CorrelationDistance#compareTo(distance) is returned.

Specified by:
compareTo in interface Comparable<PreferenceVectorBasedCorrelationDistance>
Overrides:
compareTo in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Returns:
the value of CorrelationDistance#compareTo(distance)
Throws:
IllegalArgumentException - if the dimensionality values of this distance and the specified distance are not equal

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Calls CorrelationDistance.writeExternal(java.io.ObjectOutput) and writes additionally the dimensionality and each Byte of the common preference vector to the specified stream.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Calls CorrelationDistance.readExternal(java.io.ObjectInput) and reads additionally the dimensionality and each Byte of the common preference vector from the specified stream..

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Throws:
IOException

externalizableSize

public int externalizableSize()
Returns the number of Bytes this distance uses if it is written to an external file.

Specified by:
externalizableSize in interface Distance<PreferenceVectorBasedCorrelationDistance>
Overrides:
externalizableSize in class CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
Returns:
16 + 4 * dimensionality (8 Byte for two integer, 8 Byte for a double value, and 4 * dimensionality for the bit set)

Release 0.2 (2009-07-06_1820)