curve-fitting

curve fitting estimate parameter - inverse square law

ε祈祈猫儿з 提交于 2019-12-02 07:34:18
I want to make a plot force vs position (for coulomb's law) and estimate the constant e0. I have the values of charges , q1=1,q2=1. I have for example the position=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1]; force=[0.08,0.015,0.013,0.0062,0.0016,0.00519,-0.00159,0.00118,... 0.0061,0.00155,0.00143]; Coulomb is F= (1/4*pi*e0) * q1*q2/r^2. So, it is in the form: y=ax^-m , where a= (q1*q2/4*pi*e0) I am doing: p=polyfit(-log10(position),log10(force),1); % I am not sure about '1' and minus m=p(1); a=10^(p(2)); % I am not sure about a xp=0.1:0.1:1.1; yp=a*xp.^(-m); plot(position,force,'o',xp,yp)

fitting a function with multiple data sets using gnuplot

孤者浪人 提交于 2019-12-02 07:24:06
I would like to fit a function using many data sets. For example, I reproduce an experience many times, each time I obtain a pair of data column (x,y). I put all these column in a file named 'data.txt' : first experience : x = column 1, y = column 2 second experience : x = column 3, y = column 4 third experience : x = column 5, y = column 6 ... Now I wish to fit a function y = f(x) for these data sets. I do not know if Gnuplot can do that ? If it is possible, could you please help me to correct the following command ? This one does not work. fit f(x) "data.txt" u 1:2:(0.25), "data.txt" u 3:4:

How to Fit to The Outer Shell of a Function

拟墨画扇 提交于 2019-12-02 06:35:35
I am trying to make a gaussian fit on a function that is messy. I want to only fit the exterior outer shell (these are not just the max values at each x, because some of the max values will be too low too, because the sample size is low). from scipy.optimize import curve_fit def Gauss(x, a, x0, sigma, offset): return a * np.exp(-np.power(x - x0,2) / (2 * np.power(sigma,2))) + offset def fitNormal(x, y): popt, pcov = curve_fit(Gauss, x, y, p0=[np.max(y), np.median(x), np.std(x), np.min(y)]) return popt plt.plot(xPlot,yPlot, 'k.') plt.xlabel('x') plt.ylabel('y') plt.title('Y(x)') x,y = xPlot

`nls` fails to estimate parameters of my model

守給你的承諾、 提交于 2019-12-02 06:15:19
I am trying to estimate the constants for Heaps law. I have the following dataset novels_colection : Number of novels DistinctWords WordOccurrences 1 1 13575 117795 2 1 34224 947652 3 1 40353 1146953 4 1 55392 1661664 5 1 60656 1968274 Then I build the next function: # Function for Heaps law heaps <- function(K, n, B){ K*n^B } heaps(2,117795,.7) #Just to test it works So n = Word Occurrences , and K and B are values that should be constants in order to find my prediction of Distinct Words. I tried this but it gives me an error: fitHeaps <- nls(DistinctWords ~ heaps(K,WordOccurrences,B), data =

Implementing a Broken Power Law as a fitting function in Origin

故事扮演 提交于 2019-12-02 05:56:37
Good day, I'm trying to use the function builder in origin (OriginLab) to create a new function to fit with, the broken power law ( http://en.wikipedia.org/wiki/Power_law#Broken_power_law ) So, I think I got the actual function part down. For this I used if(x<xc) y =x^a1; if(x>xc) y = x^(a1-a2)*x^a2; if(x==xc) y = 0; Where xc, a1 and a2 are the parameters. However, I then get to the point where you have to choose a bunch of stuff (parameter ranges, script you run to guess initial values, etc) and I have no clue what to put in there. Does anyone have some experience with this? Even though the

Smooth Hilbert curves

时光毁灭记忆、已成空白 提交于 2019-12-02 05:48:11
I'm trying to smooth out the path taken by a Hilbert curve . I can define the points and connect them by straight lines, but I want a path that doesn't take the edges so sharply. I attempted to connect the curve using Bezier curves of higher and higher orders but this doesn't work, there are always 'kinks' in the path as I try to reconnect them: I feel like this a solved problem, but I'm not searching for the right terms. How about using piecewise cubics for this... Does not really matter if BEZIER SPLINE or whatever. You just need to connect the patches with proper point call sequence which

fit multiple parametric curves with scipy

自闭症网瘾萝莉.ら 提交于 2019-12-02 05:23:02
问题 I have a set (at least 3) of curves (xy-data). For each curve the parameters E and T are constant but different. I'm searching the coefficients a,n and m for the best fit over all curves. y= x/E + (a/n+1)*T^(n+1)*x^m I tried curve_fit, but I have no idea how to get the parameters E and T into the function f (see curve_fit documentation). Furthermore I'm not sure if I understand xdata correctly. Doc says: An M-length sequence or an (k,M)-shaped array for functions with k predictors. What's a

Exponential curve fitting without the Curve Fitting toolbox?

耗尽温柔 提交于 2019-12-02 04:05:00
I have some data points to which I need to fit an exponential curve of the form y = B * exp(A/x) (without the help of Curve Fitting Toolbox ). What I have tried so far to linearize the model by applying log, which results in log(y/B) = A/x log(y) = A/x + log(B) I can then write it in the form Y = AX + B Now, if I neglect B , then I am able to solve it with A = pseudoinverse (X) * Y but I am stuck with values of B ... Fitting a curve of the form y = b * exp(a / x) to some data points (xi, yi) in the least-squares sense is difficult. You cannot use linear least-squares for that, because the

R: Quadratic curve is printing as dozens of lines

百般思念 提交于 2019-12-02 03:44:22
问题 Instead of printing a nice curve, R is printing a dense mess of line segments. The edge of that dense mess looks exactly like the curve I'm trying to print, though. I have datasets X2 and Y2 plotted and am trying to print a quadratic curve on the existing plot. Here's my code: X22 <- X2^2 model2s <- lm(Y2 ~ X2 + X22) plot(X2,Y2) lines(X2,fitted(model2s)) X2: [1] -2.69725933 -1.54282303 -1.91720835 -0.08528522 -2.57551112 -2.65955930 1.66190727 0.01135419 [9] -1.67597429 -0.46931267 1.31551076

Determining slopes with R code [closed]

给你一囗甜甜゛ 提交于 2019-12-02 03:33:00
I have a number of melting curves, for which I want to determine the slope of the steepest part between the minimum (valley) and maximum (peak) using R code (the slope in the inflection point corresponds to the melting point). The solutions I can imagine are either to determine the slope in every point and then find the maximum positive value, or by fitting a 4-parameter Weibull-type curve using the drc package to determine the inflection point (basically corresponding to the 50% response point between minimum and maximum). In the latter case the tricky part is that this fitting has to be