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

Re: python numpy histogram

2019-06-18 Thread Machiel Kolstein
Thank you for your fast reply. You're right, I completely missed the fact that range should be given with two numbers (which in retrospect should have been obvious). Best regards, Machiel -- Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es -- https://ma

python numpy histogram

2019-06-18 Thread Machiel Kolstein
Hi, I get the following error: ERROR: Traceback (most recent call last): File "exponential_distr.py", line 32, in numpy.histogram(data_array, bins=100, range=2) File "/usr/lib/python2.7/dist-packages/numpy/lib/function_base.py", line 499, in histogram mn, mx = [mi + 0.0 for