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

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance<D>
      extended by de.lmu.ifi.dbs.elki.distance.distancevalue.CorrelationDistance<PreferenceVectorBasedCorrelationDistance>
          extended by de.lmu.ifi.dbs.elki.distance.distancevalue.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.

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).
static PreferenceVectorBasedCorrelationDistance FACTORY
          The static factory instance
private static long serialVersionUID
          Serial version
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.distancevalue.CorrelationDistance
CORRELATION_DISTANCE_PATTERN, correlationValue, euclideanValue, SEPARATOR
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance
DOUBLE_PATTERN, INFINITY_PATTERN, INTEGER_PATTERN
 
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.
 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.
 Pattern getPattern()
          Get the pattern accepted by this distance
 PreferenceVectorBasedCorrelationDistance infiniteDistance()
          Provides an infinite distance.
 PreferenceVectorBasedCorrelationDistance minus(PreferenceVectorBasedCorrelationDistance distance)
          Returns a new Distance by subtracting the given distance from this distance.
 PreferenceVectorBasedCorrelationDistance nullDistance()
          Provides a null distance.
 PreferenceVectorBasedCorrelationDistance parseString(String pattern)
          Provides a measurement suitable to this measurement function based on the given pattern.
 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.
 PreferenceVectorBasedCorrelationDistance undefinedDistance()
          Provides an undefined distance.
 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.distancevalue.CorrelationDistance
equals, getCorrelationValue, getEuclideanValue, hashCode
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance
isInfiniteDistance, isNullDistance, isUndefinedDistance, requiredInputPattern, testInputPattern
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FACTORY

public static final PreferenceVectorBasedCorrelationDistance FACTORY
The static factory instance


serialVersionUID

private static final long serialVersionUID
Serial version

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

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.

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.

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)

getPattern

public Pattern getPattern()
Description copied from class: AbstractDistance
Get the pattern accepted by this distance

Specified by:
getPattern in class AbstractDistance<PreferenceVectorBasedCorrelationDistance>
Returns:
Pattern

parseString

public PreferenceVectorBasedCorrelationDistance parseString(String pattern)
                                                     throws IllegalArgumentException
Description copied from interface: Distance
Provides a measurement suitable to this measurement function based on the given pattern.

Parameters:
pattern - a pattern defining a similarity suitable to this measurement function
Returns:
a measurement suitable to this measurement function based on the given pattern
Throws:
IllegalArgumentException - if the given pattern is not compatible with the requirements of this measurement function

infiniteDistance

public PreferenceVectorBasedCorrelationDistance infiniteDistance()
Description copied from interface: Distance
Provides an infinite distance.

Returns:
an infinite distance

nullDistance

public PreferenceVectorBasedCorrelationDistance nullDistance()
Description copied from interface: Distance
Provides a null distance.

Returns:
a null distance

undefinedDistance

public PreferenceVectorBasedCorrelationDistance undefinedDistance()
Description copied from interface: Distance
Provides an undefined distance.

Returns:
an undefined distance

Release 0.4.0 (2011-09-20_1324)