

X = + X ) / 2 for i in range ( len ( X ) - 1 )] self.

data, bins = bins, density = True ) self.

:param data: random data :param X: evenly spaced X data :param Y: probability density of the data :param bins: if data is providede, we will compute the probability using hist function and bins may be provided. rubric:: **Constructor** One should provide either the parameter **data** alone, or the X and Y parameters, which are the histogram of some data sample. """ def _init_ ( self, data = None, X = None, Y = None, bins = None ): """. The API is probably going to change in the close future. It currently handles only gaussian distribution. plot:: from fitter import HistFit from pylab import hist import scipy.stats data = Y, X, _ = hist(data, bins=30) hf = HistFit(X=X, Y=Y) hf.fit(error_rate=0.03, Nfit=20) print(hf.mu, hf.sigma, hf.amplitude). If so, just provide them Note that the output of the hist function returns an X with N+1 values while Y has only N values. plot:: from fitter import HistFit import scipy.stats data = hf = HistFit(data, bins=30) hf.fit(error_rate=0.03, Nfit=20 ) print(hf.mu, hf.sigma, hf.amplitude) You may already have your probability density function with the X and Y series. This gives us a better estimate of the underlying mu and sigma parameters of the distribution. In this case, X should be evenly spaced If you have some data, histogram is computed, then we add some noise during the fitting process and repeat the process Nfit=20 times. If you already have the histogram, you can provide the arguments. Then, we fit a curve on top on the histogram that best fit the histogram. Class HistFit : """Plot the histogram of the data (barplot) and the fitted histogram.
