curve-fitting

MATLAB can't seem to find csaps() in MATLAB 7.10.0 student edition

青春壹個敷衍的年華 提交于 2019-12-11 03:29:11
问题 I have some code using csaps() , Matlab's cubic smoothing spline fitting function that I want to give to a student with MATLAB 7.10.0 (R2010a). For some reason the function doesn't seem to exist, even though the student has the Curve Fitting Toolbox installed: EDU>> ver ------------------------------------------------------------------------------------- MATLAB Version 7.10.0.499 (R2010a) MATLAB License Number: STUDENT Operating System: Microsoft Windows XP Version 5.1 (Build 2600: Service

R, ggplot2: Fit curve to scatter plot

限于喜欢 提交于 2019-12-11 03:09:46
问题 I am trying to fit curves to the following scatter plot with ggplot2. I found the geom_smooth function, but trying different methods and spans, I never seem to get the curves right... This is my scatter plot: And this is my best attempt: Can anyone get better curves that fit correctly and don't look so wiggly? Thanks! Find a MWE below: my.df <- data.frame(sample=paste("samp",1:60,sep=""), reads=c(523, 536, 1046, 1071, 2092, 2142, 4184, 4283, 8367, 8566, 16734, 17132, 33467, 34264, 66934,

Exponential curve fit will not fit

核能气质少年 提交于 2019-12-11 02:55:01
问题 When attempting to plot an exponential curve to a set of data: import matplotlib import matplotlib.pyplot as plt from matplotlib import style from matplotlib import pylab import numpy as np from scipy.optimize import curve_fit x = np.array([30,40,50,60]) y = np.array([0.027679854,0.055639098,0.114814815,0.240740741]) def exponenial_func(x, a, b, c): return a*np.exp(-b*x)+c popt, pcov = curve_fit(exponenial_func, x, y, p0=(1, 1e-6, 1)) xx = np.linspace(10,60,1000) yy = exponenial_func(xx,

Denormalize results of curve fit on normalized data

China☆狼群 提交于 2019-12-11 02:37:23
问题 I am fitting an exponential decay function with lsqvurcefit in Matlab . To do this I first normalize my data because they differ several orders of magnitude. However Im not sure how to denormalize my fitted parameters. My fitting model is s = O + A * exp(-t/T) where t and s are known and t is in the order of 10^-3 and s in the order of 10^5. So I subtract from them their mean and divide them by their standarddeviation. My goal is to find the best A, O and T that at the given times t will

How do I fit a function that includes an integral with a variable limit?

淺唱寂寞╮ 提交于 2019-12-11 00:07:30
问题 I'm very new to Python (and also Stack Overflow so sorry if I'm not doing this right!). I'm trying to fit the following equation to some data in order to extract the cosmological parameters ΩM and ΩΛ: Equation to fit where Curly D equation In my equation, capital curly D=Ho*dl so the Ho has been cancelled out. I'm currently trying to use the ΩM+ΩΛ=1 form. I have the data for m(z) and z, and I know the curly M constant. This is the code I have at the moment: import numpy as np import scipy

Scipy.optimize - curve fitting with fixed parameters

为君一笑 提交于 2019-12-10 23:45:19
问题 I'm performing curve fitting with scipy.optimize.leastsq . E.g. for a gaussian: def fitGaussian(x, y, init=[1.0,0.0,4.0,0.1]): fitfunc = lambda p, x: p[0]*np.exp(-(x-p[1])**2/(2*p[2]**2))+p[3] # Target function errfunc = lambda p, x, y: fitfunc(p, x) - y # Distance to the target function final, success = scipy.optimize.leastsq(errfunc, init[:], args=(x, y)) return fitfunc, final Now, I want to optionally fix the values of some of the parameters in the fit. I found that suggestions are to use

MATLAB: Piecewise function in curve fitting toolbox using fittype

早过忘川 提交于 2019-12-10 23:42:38
问题 Ignore the red fitted curve first. I'd like to get a curve to the blue datapoints. I know the first part (up to y~200 in this case) is linear, then a different curve (combination of two logarithmic curves but could also be approximated differently) and then it saturates at about 250 or 255. I tried it like this: func = fittype('(x>=0 & x<=xTrans1).*(A*x+B)+(x>=xTrans1 & x<=xTrans2).*(C*x+D)+(x>=xTrans2).*E*255'); freg = fit(foundData(:,1), foundData(:,2), func); plot(freg, foundData(:,1),

Scipy curve_fit multiple series of data

萝らか妹 提交于 2019-12-10 22:19:58
问题 I'm trying to have a curve fit that takes into account multiple series of y based on same values of x and same (exponential) law. The y values among the series vary a little since they're experimental but are still close (at same x). I tried to build two arrays: one with the x and one with the two different series of y def f(x,a,b,c): return a*numpy.exp(-b*x)+c xdata=numpy.array([data['x'],data['x']]) ydata = numpy.array([data['y1'], data['y2']]) popt, pcov=curve_fit(f,xdata,ydata) But this

B-spline fitting to 2D discrete data points (pixels of contour image)

断了今生、忘了曾经 提交于 2019-12-10 18:08:00
问题 I am trying to fit a B-spline to a set of ordered discrete data points which represent pixels of a contour extracted from an image. While the below code works fine for some simple shapes, but not for others (please see attached image for examples). Why does this happen, and what would be a better way to approach this problem? I am quite new to differential geometry, appreciate any insights or inputs. Thanks. % data contains two columns representing x,y coordinates of pixels x = data(:, 1); y

Fit a sigmoid to my data using MATLAB

有些话、适合烂在心里 提交于 2019-12-10 15:38:01
问题 I have a lot of data, and I think it is possible to fit it to a sigmoid (this thought based on my eye-sight, not a mathematical formula). How can I find the parametric form with statistically significant explanatory power of the best sigmoid for my data? Thanks! 回答1: One great thing that you can do is to use the "Curve fitting" App in Matlab. you can find it in APPS, in "Math, statistics and optimization" section. over there you can choose your x and y data and the function that you want to