medpy.features.histogram.fuzzy_histogram#

medpy.features.histogram.fuzzy_histogram(a, bins=10, range=None, normed=False, membership='triangular', smoothness=None, guarantee=False)[source]#

Compute a fuzzy histogram. The percentage of a value’s membership in a bin is computed using the selected membership function. This functions stays as near as possible to the numpy.histogram behaviour.

Parameters:
aarray_like

Input data; The histogram is computed over the flattened array (with ravel()).

binsint

The number of equal-width bins in the given range (10, by default).

range(float, float)

The lower and upper range of the bins; If not provided, range is simply (a.min(), a.max()); Values outside the range are ignored.

normedbool

If False, the result will contain the number of samples in each bin; If True, the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1.

membershipstring

Select the type of the fuzzy membership function; See package description for available options.

smoothnessfloat

The smoothness of the fuzzy function; See package description and the membership functions for more details.

guaranteebool

Guarantee that all values contribute equally to the histogram; when this value is set, the range term is ignored; see package descriptions for details.

Returns:
histarray

The values of the histogram. See normed and weights for a description of the possible semantics.

bin_edgesarray of dtype float

Return the bin edges (length(hist)+1).

Notes

See package description for more details on the usage.

Examples

>>> import numpy as np
>>> from medpy.features import fuzzy_histogram
>>> a = np.asarray([1,2,3,3.2,3.4,3.5,7.5,7.6,7.8,8,9,10])
>>> np.histogram(a, bins=4)
(array([4, 2, 2, 4]), array([  1.  ,   3.25,   5.5 ,   7.75,  10.  ]))
>>> fuzzy_histogram(a, bins=4)
(array([ 3.4       ,  2.04444444,  2.04444444,  3.4       ]), array([  1.  ,   3.25,   5.5 ,   7.75,  10.  ]))
>>> fuzzy_histogram(a, bins=4, membership='sigmoid')
(array([ 3.34304743,  2.15613626,  2.15613626,  3.34304743]), array([  1.  ,   3.25,   5.5 ,   7.75,  10.  ]))