Package elki.distance

Class 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
    • Field Detail

      • seed

        private long seed
        Seed for reproducible random.
    • Constructor Detail

      • RandomStableDistance

        public RandomStableDistance​(long seed)
        Constructor. Usually it is preferred to use the static instance!
    • 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 interface DBIDDistance
        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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • instantiate

        public <T extends DBIDDistanceQuery<T> instantiate​(Relation<T> relation)
        Description copied from interface: Distance
        Instantiate with a database to get the actual distance query.
        Specified by:
        instantiate in interface Distance<DBID>
        Parameters:
        relation - The representation to use
        Returns:
        Actual distance query.