Previous topic

medpy.metric.histogram.manhattan

Next topic

medpy.metric.histogram.noelle_1

This Page

medpy.metric.histogram.minowski

medpy.metric.histogram.minowski(h1, h2, p=2)[source]

Minowski distance.

With \(p=2\) equal to the Euclidean distance, with \(p=1\) equal to the Manhattan distance, and the Chebyshev distance implementation represents the case of \(p=\pm inf\).

The Minowksi distance between two histograms \(H\) and \(H'\) of size \(m\) is defined as:

\[d_p(H, H') = \left(\sum_{m=1}^M|H_m - H'_m|^p \right)^{\frac{1}{p}}\]

Attributes:

  • a real metric

Attributes for normalized histograms:

  • \(d(H, H')\in[0, \sqrt[p]{2}]\)
  • \(d(H, H) = 0\)
  • \(d(H, H') = d(H', H)\)

Attributes for not-normalized histograms:

  • \(d(H, H')\in[0, \infty)\)
  • \(d(H, H) = 0\)
  • \(d(H, H') = d(H', H)\)

Attributes for not-equal histograms:

  • not applicable
Parameters:

h1 : sequence

The first histogram.

h2 : sequence

The second histogram.

p : float

The \(p\) value in the Minowksi distance formula.

Returns:

minowski : float

Minowski distance.

Raises:

ValueError

If p is zero.