#### Previous topic

medpy.metric.histogram.chebyshev_neg

#### Next topic

medpy.metric.histogram.correlate

# medpy.metric.histogram.chi_square¶

medpy.metric.histogram.chi_square(h1, h2)[source]

Chi-square distance.

Measure how unlikely it is that one distribution (histogram) was drawn from the other. The Chi-square distance between two histograms $$H$$ and $$H'$$ of size $$m$$ is defined as:

$d_{\chi^2}(H, H') = \sum_{m=1}^M \frac{ (H_m - H'_m)^2 }{ H_m + H'_m }$

Attributes:

• semimetric

Attributes for normalized histograms:

• $$d(H, H')\in[0, 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. chi_square : float Chi-square distance.