Package elki.distance

Class RandomStableDistance

  • All Implemented Interfaces:
    DBIDDistance, Distance<DBID>

    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.
    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
        o1 - first object id
        o2 - second object id
        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.
        seed - Seed value
        input - Input code
        Pseudo random double value
      • toString

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

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

        public int hashCode()
        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>
        relation - The representation to use
        Actual distance query.