# Tag Info

24

Fitting an ellipse: i = Import["http://i.stack.imgur.com/W7HJk.jpg"]; lineByCenter[center_, semi_, angle_] := Rotate[Line[{#1 - #2, #1 + #2}], angle, #1]& [center,{0,semi}] sa = 1 /. ComponentMeasurements[ Binarize@i, "SemiAxes"] angle = 1 /. ComponentMeasurements[ Binarize@i, ...

17

If you need more precise calculation you may check this answer. cm = ComponentMeasurements[Binarize@img, "BoundingDiskRadius"] ct = 1 /. ComponentMeasurements[Binarize@img, "BoundingDiskCenter"]; Show[img, Graphics[{Thick, White, Circle[ct, cm[[1, 2]]]}]] {1 -> 63.4933}

11

Because you are implying that you have a random sample of values of $v$ from a specified probability distribution, you should consider using maximum likelihood rather than least squares. (In fact, I must comment that in this forum least squares seems to be often used for the estimation of parameters given a random sample which I would argue is almost never ...

10

So imagine you do not know the background formula. This can be done in a beautiful way with FindFormula. Generate data: f[x_] := Exp[-(x - 7)^2] + Exp[-(x + 5)^2] - .002 x^2 data = Table[{x, f[x] + .1 RandomReal[{-1, 1}]}, {x, -15, 15, .1}]; Plot[f[x], {x, -15, 15}, PlotRange -> All, Epilog -> {Red, Point[data]}] Now use FindFormula to learn ...

7

This documentation page spells out how EstimatedVariance is computed. It is the "squared sum of FitResiduals divided by the degrees of freedom $n-p$. A linear regression will also have an intercept term, in addition to terms corresponding to each of the predictor columns. For example, headings = ExampleData[{"Statistics", "FisherIris"}, "ColumnHeadings"]; ...

7

numHist = numHist/Tr@numHist/vHist[[2]] // N; data = Transpose[{MovingAverage[vHist, 2], numHist}]; m = 5.99736*10^-13;(*particle mass in kg*) k = 1.3806488*10^-23;(*Boltzmann constant in J/K*) model = m/(k*T)*v*Exp[-m*v^2/(2*k*T)]; fit = FindFit[data, model, {{T, 10}}, v] modelf = Function[{v}, Evaluate[model /. fit]]; Plot[modelf[t], {t, 0, 0.0009}, Epilog ...

5

A common approach is to blank/mask out the signal and fit a polynomial to the remaining data. A problem to avoid here is overfitting, i.e. fitting some high-order polynomial to the noise structure. Taking the artifical data from Vitaliy's answer: f[x_] := Exp[-(x - 7)^2] + Exp[-(x + 5)^2] - .002 x^2 data = Table[{x, f[x] + .1 RandomReal[{-1, 1}]}, {x, ...

4

Fit works using singular value decomposition. FindFit uses the same method for the linear least-squares case, the Levenberg–Marquardt method for nonlinear least-squares, and general FindMinimum methods for other norms. - source NonlinearModelFit allows fitting of weighted data, as J.M. commented Edit: The best fit parameters are a property of the ...

4

Another approach that might be successful with some additional fine tuning. pos = (pic = Import["http://i.stack.imgur.com/9uBnQ.png"]) // Thinning // PixelValuePositions[#, 1] &; center = Mean /@ Transpose[pos] // N; out = Reap[ Module[{nextPos = {pos[[690]]}, newList = pos, delta = {-1., 1.}, lastPos = {pos[[690]]}}, Do[ ...

4

Not so much of an answer, but an extended comment, but I think I have it very nearly nailed: pos2 = (# - Mean@pos & /@ (N@pos)) // #/Mean@(Norm /@ #) & Manipulate[ Show[ListPlot[Reverse /@ pos2], PolarPlot[Sqrt[a b]/Sqrt[ a^2 Cos[c x]^2 + b^2 Sin[c x]^2], {x, -4.1 \[Pi], 4.1 \[Pi]}, PlotStyle -> Orange]], {a, 1, 15}, {b, 1, 15}, ...

4

Here it is with the constraint. I changed the symbols to a,x just for readability (There was nothing wrong with the y,F except that single Caps are good to avoid ) nlm = NonlinearModelFit[ test, {((Sqrt[a] + Sqrt[x + a])^2)^(2/3) - Sqrt[a ((Sqrt[a] + Sqrt[x + a])^2)^(1/3)] - ((Sqrt[a] + Sqrt[a])^2)^(2/3) - Sqrt[a ((Sqrt[a] + ...

3

Both plots are differently scaled, so I propose to use Overlay with two Y-axes list = {{1965., 18.5592}, {1966., 19.109}, {1967., 19.6698}, {1968., 20.2349}, {1969., 20.7953}, {1970., 21.3448}, {1971., 21.8802}, {1972., 22.4043}, {1973., 22.9248}, {1974., 23.4527}, {1975., 23.9962}, {1976., 24.5576}, {1977., 25.1346}, ...

3

The problem is a case of the starting values (1.0 for both parameters) being too far away from the solution. (And you should avoid uppercase letters for variable names.) The following works: model1 = FindFit[j, m/(1 + Exp[po + r t]), {{m, 500}, {r, -0.008}}, t] (* {m -> 527.775, r -> -0.00797179} *) Alternatively, a better long-term approach is to ...

3

You can get an approximation with NDSolve fairly easily for each of the four branches of the curve for which $y$ is a function of $x$. You can also get symbolic solutions in polar coordinates for each of the two branches for with $\theta$ is a function of $r$ (the reverse of the usual relationship sought). First the polar: eqOP = Rationalize[-(1/2) + ...

3

You could do for example: int[al_?NumericQ, be_?NumericQ] := NIntegrate[(funcr[al, be, x] - piece[x])^2, {x, 0, 1}] nm = NMinimize[{int[al, be], al >= 1, be >= 1}, {al, be}] Plot[{piece@x, funcr[al, be, x] /. nm[[2]]}, {x, 0, 1}, PlotStyle -> {{Thickness[.01], Red}, {Dashed, Thickness[.01], Blue}}]

3

I am not quite following what you are trying to do with norm or max. The procedure I followed was to make some data from your fake empirical cumulative probability function. piece[x_] := Piecewise[{{x^3, 1 >= x >= 0}, {1, x > 1}}, 0]; data = Table[{x, piece[x]}, {x, 0, 1, 0.02}]; Copy and paste your "model" funcr[al_?NumericQ, be_?NumericQ, ...

2

Your datatest has one too many parenthesis. Dont use func, replace it with the evaluated integral. Integrate[(a ((x - y)/(1 - y))^2 + b ((x - y)/(1 - y)) + c) (d y^2 + e y + f), {y, 0, x}, Assumptions -> {0 < x < 1}] (* 1/6 x (6 (c f + b (d + e + f) + a (4 d + 3 e + 2 f)) - 3 (-c e + b (d + e) + a (8 d + 5 e + 2 f)) x + (2 a - b + ...

2

The following trick sometimes work: f[a_?NumericQ, x_?NumericQ] := Module[{s = ((Sqrt[a] + Sqrt[x + a])^2)^(2/3) - Sqrt[a ((Sqrt[a] + Sqrt[x + a])^2)^(1/3)] - ((Sqrt[a] + Sqrt[a])^2)^(2/3) - Sqrt[a ((Sqrt[a] + Sqrt[a])^2)^(1/3)] + 5}, 10^3 Im@s + Re@s] nlm = NonlinearModelFit[test, {f[a, x]}, {a}, x, ...

2

AFAIK - no. But since you asking. Suppose you have this Data: xdata = {1, 2, 3, 4, 5}; ydata = {1, 2, 3, 4, 5}; and this Errors: err1 = 0.3 err2 = 0.35 Giving you lp1 = ListPlot[{xdata, ydata}, PlotStyle -> Green] and lm = LinearModelFit[Transpose[{xdata, ydata}], x, x] lm["BestFit"] -3.57485*10^-15 + 1. x p1 = Plot[{lm[x]}, {x, maX + ...

2

FindFit can fit a dataset to an arbitrary function, including piecewise functions (which appears to be your intended model). As an example dataset: dat = Table[{x + 5, 2 + 0.5 RandomReal[] + Piecewise[{{-x, x < 0}, {2 x, x >= 0}}]}, {x, -3, 5, 0.1}]; ListPlot[dat] You can then use FindFit to find a fit: model = d + Piecewise[{{a (x - ...

1

You were very unclear about what your actual question is. But I'm trying to procrastinate so here's what I would do, data = Get["http://pastebin.com/raw.php?i=FeEa2MU9"]; lorentzianModel = y0 - a/(b + (x - x0)^2); I took your CSV file, which you generally can't ask people on this site to download, imported it, and used the command ...

1

Update To start you have one data point that needs to be fixed. 7.94834000000012*E-05 -> 7.94834000000012*10^-5. Probably copied from a different format for numbers. Examine the data I am going to use the form from your original question. Using the minus sign in the exponent Jos*(Exp[-Voc/A/n] is not helpful. My understanding is that you have a ...

Only top voted, non community-wiki answers of a minimum length are eligible