skbio.stats.distance.
randdm
(num_objects, ids=None, constructor=None, random_fn=None)[source]¶Generate a distance matrix populated with random distances.
State: Experimental as of 0.4.0.
Using the default random_fn, distances are randomly drawn from a uniform
distribution over [0, 1)
.
Regardless of random_fn, the resulting distance matrix is guaranteed to be symmetric and hollow.
num_objects (int) – The number of objects in the resulting distance matrix. For example, if num_objects is 3, a 3x3 distance matrix will be returned.
ids (sequence of str or None, optional) – A sequence of strings to be used as IDs. len(ids)
must be equal to
num_objects. If not provided, IDs will be monotonically-increasing
integers cast as strings (numbering starts at 1). For example,
('1', '2', '3')
.
constructor (type, optional) – DissimilarityMatrix or subclass constructor to use when creating the
random distance matrix. The returned distance matrix will be of this
type. If None
(the default), a DistanceMatrix instance will be
returned.
random_fn (function, optional) – Function to generate random values. random_fn must accept two
arguments (number of rows and number of columns) and return a 2D
numpy.ndarray
of floats (or something that can be cast to float).
If None
(the default), numpy.random.rand
will be used.
DissimilarityMatrix (or subclass) instance of random distances. Type depends on constructor.
See also
numpy.random.rand()