If I have an array with values, which are distributed according to a Gaussian function, then I can fit with: (fit_mu, fit_sigma) = stats.norm.fit(x_array)
However, now, I have one array with values for the xbins (e.g., 0.0, 0.1, 0.2, 0.3, ..., up till 1.0) and one value for the corresponding y-value (e.g. 0.0, 0.3, 0.6, 1.2, 5.0, 10.0, 5.0, 1.2, 0.6, 0.3, 0.0). (These values are just an example). Now I want to fit this, with a Gauss. So, obviously I don't want to fit over neither the values in xbins, nor the y_array (neither of which is normal distributed) but over the y values for each x bin. The only thing I can think of is looping over all bins, and then filling an artificial array: for i in range(0, Nbins): x = xbinvalue(i) weight = y_value_for_this_x(x) for w in range(0, weight) numpy.vstack((tmp_array, x) (fit_mu, fit_sigma) = scipy.stats.norm.fit(tmp_array) But this seems a rather silly way of doing this. Is there an other way? Cheers, Machiel -- Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es <http://legal.ifae.es/> -- https://mail.python.org/mailman/listinfo/python-list