### Navigation

- index
- modules |
- modules |
- next |
- previous |
- SciPy v0.12 Reference Guide (DRAFT) »
- Spatial algorithms and data structures (`scipy.spatial`) »

# scipy.spatial.distance_matrix

`scipy.spatial.``distance_matrix`(x, y, p=2, threshold=1000000)

  Compute the distance matrix.

  Returns the matrix of all pair-wise distances.

  Parameters : | x : (M, K) array_like TODO: description needed y : (N, K) array_like TODO: description needed p : float, 1 <= p <= infinity Which Minkowski p-norm to use. threshold : positive int If `M * N * K` > threshold, algorithm uses a Python loop instead of large temporary arrays.
  Returns : | result : (M, N) ndarray Distance matrix.

  Examples

      >>> distance_matrix([[0,0],[0,1]], [[1,0],[1,1]])
      array([[ 1.        ,  1.41421356],
             [ 1.41421356,  1.        ]])

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- SciPy v0.12 Reference Guide (DRAFT) »
- Spatial algorithms and data structures (`scipy.spatial`) »