Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance
Class CorrelationDistance<D extends CorrelationDistance<D>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.AbstractDistance<D>
      extended by de.lmu.ifi.dbs.elki.distance.CorrelationDistance<D>
Type Parameters:
D - distance type
All Implemented Interfaces:
Distance<D>, Externalizable, Serializable, Comparable<D>
Direct Known Subclasses:
PreferenceVectorBasedCorrelationDistance

public class CorrelationDistance<D extends CorrelationDistance<D>>
extends AbstractDistance<D>

The correlation distance is a special Distance that indicates the dissimilarity between correlation connected objects. The correlation distance between two points is a pair consisting of the correlation dimension of two points and the euclidean distance between the two points.

Author:
Elke Achtert
See Also:
Serialized Form

Field Summary
private  int correlationValue
          The correlation dimension.
private  double euclideanValue
          The euclidean distance.
private static long serialVersionUID
          Generated SerialVersionUID.
 
Constructor Summary
CorrelationDistance()
          Empty constructor for serialization purposes.
CorrelationDistance(int correlationValue, double euclideanValue)
          Constructs a new CorrelationDistance object consisting of the specified correlation value and euclidean value.
 
Method Summary
 int compareTo(D other)
          Compares this CorrelationDistance with the given CorrelationDistance wrt the represented correlation values.
 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.
 int getCorrelationValue()
          Returns the correlation dimension between the objects.
 double getEuclideanValue()
          Returns the euclidean distance between the objects.
 int hashCode()
          Any extending class should implement a proper hashCode method.
 D minus(D distance)
          Returns a new Distance by subtracting the given distance from this distance.
 D plus(D distance)
          Returns a new distance as sum of this distance and the given distance.
 void readExternal(ObjectInput in)
          Reads the correlation value and the euclidean value of this CorrelationDistance from the specified stream.
 String toString()
          Returns a string representation of this CorrelationDistance.
 void writeExternal(ObjectOutput out)
          Writes the correlation value and the euclidean value of this CorrelationDistance to the specified stream.
 
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
Generated SerialVersionUID.

See Also:
Constant Field Values

correlationValue

private int correlationValue
The correlation dimension.


euclideanValue

private double euclideanValue
The euclidean distance.

Constructor Detail

CorrelationDistance

public CorrelationDistance()
Empty constructor for serialization purposes.


CorrelationDistance

public CorrelationDistance(int correlationValue,
                           double euclideanValue)
Constructs a new CorrelationDistance object consisting of the specified correlation value and euclidean value.

Parameters:
correlationValue - the correlation dimension to be represented by the CorrelationDistance
euclideanValue - the euclidean distance to be represented by the CorrelationDistance
Method Detail

plus

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

Parameters:
distance - the distance to be added to this distance
Returns:
a new distance as sum of this distance and the given distance

minus

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

Parameters:
distance - the distance to be subtracted from this distance
Returns:
a new Distance by subtracting the given distance from this distance

description

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

Returns:
a String as description of this Distance

toString

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

Specified by:
toString in interface Distance<D extends CorrelationDistance<D>>
Overrides:
toString in class Object
Returns:
the correlation value and the euclidean value separated by blank

compareTo

public int compareTo(D other)
Compares this CorrelationDistance with the given CorrelationDistance wrt the represented correlation values. If both values are considered to be equal, the euclidean values are compared. Subclasses may need to overwrite this method if necessary.

Returns:
the value of Integer.compareTo(Integer) this.correlationValue.compareTo(other.correlationValue)} if it is a non zero value, the value of Double.compare(this.euclideanValue, other.euclideanValue) otherwise

hashCode

public int hashCode()
Description copied from class: AbstractDistance
Any extending class should implement a proper hashCode method.

Specified by:
hashCode in class AbstractDistance<D extends CorrelationDistance<D>>

getCorrelationValue

public int getCorrelationValue()
Returns the correlation dimension between the objects.

Returns:
the correlation dimension

getEuclideanValue

public double getEuclideanValue()
Returns the euclidean distance between the objects.

Returns:
the euclidean distance

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Writes the correlation value and the euclidean value of this CorrelationDistance to the specified stream.

Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Reads the correlation value and the euclidean value of this CorrelationDistance from the specified stream.

Throws:
IOException

externalizableSize

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

Returns:
12 (4 Byte for an integer, 8 Byte for a double value)

Release 0.2 (2009-07-06_1820)