medpy.features.histogram.triangular_membership#

medpy.features.histogram.triangular_membership(bin_center, bin_width, smoothness=0.5)[source]#

Create a triangular membership function for a fuzzy histogram bin.

Parameters:
bin_centernumber

The center of the bin of which to compute the membership function.

bin_widthnumber

The width of a single bin (all expected to be of equal width).

smoothnessnumber, optional

The smoothness of the function; determines the neighbourhood affected. See below and fuzzy_histogram for a more detailed explanation

Returns:
triangular_membershipfunction

A triangular membership function centered on the bin.

Notes

For the triangular function the smoothness factor has to be 0.5. Lower values are accepted, but then the function assumes the shape of the trapezium membership function. Higher values lead to an exception.

The triangular membership function is defined as

\[\begin{split}\mu_{\triangle}(x) = \left\{ \begin{array}{ll} 0, & x<a, x>c\\ \frac{x-a}{b-a}, & a\leq x\leq b \\ \frac{c-x}{c-b}, & b<x\leq c\\ \end{array} \right.\end{split}\]

where \(a\) is the left border, \(c\) the right border and \(b\) the center of the triangular function. The height of the triangle is chosen such, that all values contribute with exactly one.

The standard triangular function (\(smoothness = 0.5\)) is displayed in the following figure

“Triangular functions (1)”

where the bin width is \(2\) with centers at \(-2\), \(0\) and \(2\).