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

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

public abstract 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.

See Also:
Serialized Form

Field Summary
static Pattern CORRELATION_DISTANCE_PATTERN
          The pattern used for correlation distances
protected  int correlationValue
          The correlation dimension.
protected  double euclideanValue
          The euclidean distance.
static String SEPARATOR
          The component separator used by correlation distances.
private static long serialVersionUID
          Generated SerialVersionUID.
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance
DOUBLE_PATTERN, INFINITY_PATTERN, INTEGER_PATTERN
 
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.
 boolean equals(Object obj)
          Returns true if this == o has the value true or o is not null and o is of the same class as this instance and this.compareTo(o) is 0, false otherwise.
 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.
 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.distancevalue.AbstractDistance
getPattern, isInfiniteDistance, isNullDistance, isUndefinedDistance, requiredInputPattern, testInputPattern
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancevalue.Distance
infiniteDistance, minus, nullDistance, parseString, plus, undefinedDistance
 

Field Detail

SEPARATOR

public static final String SEPARATOR
The component separator used by correlation distances. Note: Do NOT use regular expression syntax characters!

See Also:
Constant Field Values

CORRELATION_DISTANCE_PATTERN

public static final Pattern CORRELATION_DISTANCE_PATTERN
The pattern used for correlation distances


serialVersionUID

private static final long serialVersionUID
Generated SerialVersionUID.

See Also:
Constant Field Values

correlationValue

protected int correlationValue
The correlation dimension.


euclideanValue

protected 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

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

equals

public boolean equals(Object obj)
Description copied from class: AbstractDistance
Returns true if this == o has the value true or o is not null and o is of the same class as this instance and this.compareTo(o) is 0, false otherwise.

Overrides:
equals 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.4.0 (2011-09-20_1324)