curve-fitting

Gnuplot smooth confidence band

旧城冷巷雨未停 提交于 2019-12-07 14:31:24
问题 According to the answer given in this question Gnuplot smooth confidence interval lines as opposed to error bars I was able to get the same result for my data given by (the error of y is symmetric so it is y plus/minus errorY): # x y errorY 1 3 0.6 2 5 0.4 3 4 0.2 4 3.5 0.3 Code: set style fill transparent solid 0.2 noborder plot 'data.dat' using 1:($2-$3):($2+$3) with filledcurves title '95% confidence', \ '' using 1:2 with lp lt 1 pt 7 ps 1.5 lw 3 title 'mean value' Now the confidence band

fitting two dimensional curves in matlab

我与影子孤独终老i 提交于 2019-12-07 13:04:46
问题 There's a toolbox function for the curve fitting toolbox called cftool that lets you fit curves to 1-d data. Is there anything for 2-d data? 回答1: Jerry suggested two very good choices. There are other options though, if you want a more formulaic form for the model. The curvefitting toolbox, in the current version, allows you to fit surfaces to data, not just curves. Or fit a 2-d polynomial model, using a tool like polyfitn. Or you can use a nonlinear regression, if you have a model in mind.

fit (triple-) gauss to data python

懵懂的女人 提交于 2019-12-07 11:27:41
问题 The short version of my problem is the following: I have a histogram of some data (density of planets) which seems to have 3 peeks. Now I want to fit 3 gaussians to this histogram. I am expecting this outcome. I used different methods to fit my gauss: curve_fit, least square and GaussianMixture from sklearn.mixture. With Curve_fit I get a pretty good fit but it isn't good enough if you compare it to my expected outcome. With least square I get a "good fit" but my gaussians are nonsense, and

class method as a model function for scipy.optimize.curve_fit

喜你入骨 提交于 2019-12-07 10:12:58
问题 There is a statement in the manual of curve_fit that The model function, f(x, ...). It must take the independent variable as the first argument and the parameters to fit as separate remaining arguments. However, I would like to use as a model function a method of the class which is defined as: def model_fun(self,x,par): So, the first argument is not an independent variable, as you can see. Is there any way how I can use the method of a class as a model function for curve_fit 回答1: Sure, create

curve_fit failing on even a sine wave

拜拜、爱过 提交于 2019-12-07 07:35:10
问题 I'm trying to use curve_fit to fit a simple sine wave (not even with any noise) as a test before I move on to more complex problems. Unfortunately it's not giving even remotely the right answer. Here's my syntax: x = linspace(0,100,300) y = sin(1.759*x) def mysine(x, a): return sin(a*x) popt, pcov = curve_fit(mysine, x, y) popt array([ 0.98679056]) And then if I try an initial guess (say 1.5): popt, pcov = curve_fit(mysine, x, y, p0=1.5) popt array([ 1.49153365]) ... which is still nowhere

SciPy leastsq fit to a sine wave failing

时间秒杀一切 提交于 2019-12-07 05:04:40
问题 I am trying to figure out what it is I don't understand here. I am following http://www.scipy.org/Cookbook/FittingData and trying to fit a sine wave. The real problem is satellite magnetometer data which makes a nice sine wave on a spinning spacecraft. I created a dataset then am trying to fit it to recover the inputs. Here is my code: import numpy as np from scipy import optimize from scipy.optimize import curve_fit, leastsq import matplotlib.pyplot as plt class Parameter: def __init__(self,

Fitting exponential function through two data points with scipy curve_fit

折月煮酒 提交于 2019-12-07 05:00:50
问题 I want to fit an exponential function y=x ** pw with a constant pw to fit through two datapoints. The scipy curve_fit function should optimise adj1 and adj2 . I have tried with the code below but couldn't get it to work. The curve does not go through the datapoints. How can I fix it? import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit def func(x, adj1,adj2): return np.round(((x+adj1) ** pw) * adj2, 2) x = [0.5,0.85] # two given datapoints to which the

Why does scipy.optimize.curve_fit not produce a line of best fit for my points?

有些话、适合烂在心里 提交于 2019-12-07 02:27:07
问题 I have a set of data points, (x and y in the code below) and I am trying to create a linear line of best fit through my points. I am using scipy.optimize.curve_fit . My code produces a line, but not a line of best fit. I have tried giving the function model parameters to use for my gradient and for my intercept, but each time it produces the exact same line which does not fit to my data points. The blue dots are my data points the red line should be fitted to: If anyone could point out where

MATLAB - interpolating a 2D curve with multiple Y's per X

有些话、适合烂在心里 提交于 2019-12-06 16:29:40
问题 I would like to interpolate a data set, but a given X can have multiple Y's, example given below: A(:,1:2,1)= 95.2343 70.6159 96.4501 71.5573 97.4430 72.7315 98.9743 72.8699 100.0470 71.7690 100.3872 70.2699 100.7797 68.7837 102.1478 68.0814 103.6851 68.0521 105.0307 68.7966 105.8972 70.0666 106.7177 71.3665 107.7095 72.5416 108.9175 73.4924 110.3574 74.0309 111.8943 73.9859 113.3936 73.6446 114.6645 72.7794 115.5911 71.5522 116.2426 70.1591 116.3922 68.6286 116.3503 67.0914 116.7771 65.6147

How can I fit my plots from measured data?

匆匆过客 提交于 2019-12-06 11:31:05
问题 How can I fit my plots? Up to now, I've got the following code, which plots a variety of graphs from an array (data from an experiment) as it is placed in a loop: import matplotlib as plt plt.figure(6) plt.semilogx(Tau_Array, Correlation_Array, '+-') plt.ylabel('Correlation') plt.xlabel('Tau') plt.title("APD" + str(detector) + "_Correlations_log_graph") plt.savefig(DataFolder + "/APD" + str(detector) + "_Correlations_log_graph.png") This works so far with a logarithmic plot, but I am