Skip to main content
`Ctrl`+`K`

# skbio.stats.distance.DistanceMatrix.permute

DistanceMatrix.permute(condensed=False)

  Randomly permute both rows and columns in the matrix.

  Randomly permutes the ordering of rows and columns in the matrix. The same permutation is applied to both rows and columns in order to maintain symmetry and hollowness. Only the rows/columns in the distance matrix are permuted; the IDs are not permuted.

  Parameters:
    condensed bool, optional

      If `True`, return the permuted distance matrix in condensed format. Otherwise, return the permuted distance matrix as a new `DistanceMatrix` instance.

  Returns:
    DistanceMatrix or ndarray

      Permuted distances as a new `DistanceMatrix` or as a `ndarray` in condensed format.

  See also

  `condensed_form`

  Notes

  This method does not modify the distance matrix that it is called on. It is more efficient to pass `condensed=True` than permuting the distance matrix and then converting to condensed format.