de.lmu.ifi.dbs.elki.distance.distancefunction
Class RandomStableDistanceFunction

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDBIDDistanceFunction<DoubleDistance>
      extended by de.lmu.ifi.dbs.elki.distance.distancefunction.RandomStableDistanceFunction
All Implemented Interfaces:
DBIDDistanceFunction<DoubleDistance>, DistanceFunction<DBID,DoubleDistance>, InspectionUtilFrequentlyScanned, Parameterizable

public class RandomStableDistanceFunction
extends AbstractDBIDDistanceFunction<DoubleDistance>

This is a dummy distance providing random values (obviously not metrical), useful mostly for unit tests and baseline evaluations: obviously this distance provides no benefit whatsoever. This distance is based on the combined hash codes of the two objects queried, if they are different. Extra caution is done to ensure symmetry and objects with the same ID will have a distance of 0. Obviously this distance is not metrical.


Nested Class Summary
static class RandomStableDistanceFunction.Parameterizer
          Parameterization class.
 
Field Summary
private  long seed
          Seed for reproducible random.
static RandomStableDistanceFunction STATIC
          Static instance
 
Constructor Summary
RandomStableDistanceFunction(long seed)
          Constructor.
 
Method Summary
 DoubleDistance distance(DBID o1, DBID o2)
          Returns the distance between the two objects specified by their object ids.
 boolean equals(Object obj)
           
 DoubleDistance getDistanceFactory()
          Method to get the distance functions factory.
 int hashCode()
           
private  double pseudoRandom(long seed, int input)
          Pseudo random number generator, adaption of the common rand48 generator which can be found in C (man drand48), Java and attributed to Donald Knuth.
 String toString()
           
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDBIDDistanceFunction
getInputTypeRestriction, instantiate, isMetric, isSymmetric
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STATIC

public static final RandomStableDistanceFunction STATIC
Static instance


seed

private long seed
Seed for reproducible random.

Constructor Detail

RandomStableDistanceFunction

public RandomStableDistanceFunction(long seed)
Constructor. Usually it is preferred to use the static instance!

Method Detail

distance

public DoubleDistance distance(DBID o1,
                               DBID o2)
Description copied from interface: DBIDDistanceFunction
Returns the distance between the two objects specified by their object ids.

Specified by:
distance in interface DBIDDistanceFunction<DoubleDistance>
Specified by:
distance in class AbstractDBIDDistanceFunction<DoubleDistance>
Parameters:
o1 - first object id
o2 - second object id
Returns:
the distance between the two objects specified by their object ids

pseudoRandom

private double pseudoRandom(long seed,
                            int input)
Pseudo random number generator, adaption of the common rand48 generator which can be found in C (man drand48), Java and attributed to Donald Knuth.

Parameters:
seed - Seed value
input - Input code
Returns:
Pseudo random double value

getDistanceFactory

public DoubleDistance getDistanceFactory()
Description copied from interface: DistanceFunction
Method to get the distance functions factory.

Specified by:
getDistanceFactory in interface DistanceFunction<DBID,DoubleDistance>
Specified by:
getDistanceFactory in class AbstractDBIDDistanceFunction<DoubleDistance>
Returns:
Factory for distance objects

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Release 0.4.0 (2011-09-20_1324)