Package elki.distance
Class RandomStableDistance
- java.lang.Object
-
- elki.distance.AbstractDatabaseDistance<DBID>
-
- elki.distance.RandomStableDistance
-
- All Implemented Interfaces:
DBIDDistance,Distance<DBID>
@Priority(-100) public class RandomStableDistance extends AbstractDatabaseDistance<DBID> implements DBIDDistance
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.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRandomStableDistance.ParParameterization class.-
Nested classes/interfaces inherited from class elki.distance.AbstractDatabaseDistance
AbstractDatabaseDistance.Instance<O>
-
-
Field Summary
Fields Modifier and Type Field Description private longseedSeed for reproducible random.static RandomStableDistanceSTATICStatic instance
-
Constructor Summary
Constructors Constructor Description RandomStableDistance(long seed)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubledistance(DBIDRef o1, DBIDRef o2)Returns the distance between the two objects specified by their object ids.booleanequals(java.lang.Object obj)TypeInformationgetInputTypeRestriction()Get the input data type of the function.inthashCode()<T extends DBID>
DistanceQuery<T>instantiate(Relation<T> relation)Instantiate with a database to get the actual distance query.private doublepseudoRandom(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.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface elki.distance.Distance
isMetric, isSquared, isSymmetric
-
-
-
-
Field Detail
-
STATIC
public static final RandomStableDistance STATIC
Static instance
-
seed
private long seed
Seed for reproducible random.
-
-
Method Detail
-
distance
public double distance(DBIDRef o1, DBIDRef o2)
Description copied from interface:DBIDDistanceReturns the distance between the two objects specified by their object ids.- Specified by:
distancein interfaceDBIDDistance- Parameters:
o1- first object ido2- 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 valueinput- Input code- Returns:
- Pseudo random double value
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getInputTypeRestriction
public TypeInformation getInputTypeRestriction()
Description copied from interface:DistanceGet the input data type of the function.- Specified by:
getInputTypeRestrictionin interfaceDistance<DBID>- Returns:
- Type restriction
-
instantiate
public <T extends DBID> DistanceQuery<T> instantiate(Relation<T> relation)
Description copied from interface:DistanceInstantiate with a database to get the actual distance query.- Specified by:
instantiatein interfaceDistance<DBID>- Parameters:
relation- The representation to use- Returns:
- Actual distance query.
-
-