Re: Fit to function values with numpy/scipy

2019-11-25 Thread Richard Damon
On 11/25/19 12:31 PM, Machiel Kolstein wrote: > Okay, I found some answer myself: use scipy.optimize.curve_fit > However, I still find it strange that I have to define a gauss function > myself instead of it being readily available. I did this: > > # Define model function to be used to fit to the

Re: Fit to function values with numpy/scipy

2019-11-25 Thread Machiel Kolstein
Okay, I found some answer myself: use scipy.optimize.curve_fit However, I still find it strange that I have to define a gauss function myself instead of it being readily available. I did this: # Define model function to be used to fit to the data def gauss(x, *p): A, mu, sigma = p retur

Fit to function values with numpy/scipy

2019-11-25 Thread Machiel Kolstein
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 correspondin