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 class
RandomStableDistance.Par
Parameterization class.-
Nested classes/interfaces inherited from class elki.distance.AbstractDatabaseDistance
AbstractDatabaseDistance.Instance<O>
-
-
Field Summary
Fields Modifier and Type Field Description private long
seed
Seed for reproducible random.static RandomStableDistance
STATIC
Static instance
-
Constructor Summary
Constructors Constructor Description RandomStableDistance(long seed)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(DBIDRef o1, DBIDRef o2)
Returns the distance between the two objects specified by their object ids.boolean
equals(java.lang.Object obj)
TypeInformation
getInputTypeRestriction()
Get the input data type of the function.int
hashCode()
<T extends DBID>
DistanceQuery<T>instantiate(Relation<T> relation)
Instantiate with a database to get the actual distance query.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.java.lang.String
toString()
-
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:DBIDDistance
Returns the distance between the two objects specified by their object ids.- Specified by:
distance
in 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:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getInputTypeRestriction
public TypeInformation getInputTypeRestriction()
Description copied from interface:Distance
Get the input data type of the function.- Specified by:
getInputTypeRestriction
in interfaceDistance<DBID>
- Returns:
- Type restriction
-
instantiate
public <T extends DBID> DistanceQuery<T> instantiate(Relation<T> relation)
Description copied from interface:Distance
Instantiate with a database to get the actual distance query.- Specified by:
instantiate
in interfaceDistance<DBID>
- Parameters:
relation
- The representation to use- Returns:
- Actual distance query.
-
-