Tag Info

Hot answers tagged

18

vars = {w, x, y, z}; terms = MonomialList[(Plus @@ vars)^3] /. _Integer x_ :> x; cols = Join @@ {vars, terms} (* {w,x,y,z,w^3,w^2 x,w^2 y,w^2 z,w x^2,w x y,w x z,w y^2, w y z,w z^2,x^3,x^2 y,x^2 z,x y^2,x y z,x z^2,y^3,y^2 z,y z^2,z^3} *) For the data dt = Table[Join[RandomInteger[10, 4], {RandomReal[]}], {100}]; evaluate all models with up to ...


11

data = Table[{i, i}, {i, 10}]; model = a + b x ^2; Unrestricted model: nlm = NonlinearModelFit[data, model, {a, b}, x] // Normal $ 0.0863422 x^2+2.17582 $ Model restricted to pass through {5,5}: nlmr = NonlinearModelFit[data, {model, (model /. x -> 5 ) == 5}, {a, b}, x] // Normal $ 0.0790502 x^2+3.02375 $ Picture: Show[Plot[{nlm, ...


7

NMinimize[] with the Automatic method works nice ... sometimes. You can help it by providing a better choice. Like in: ts1 = {{682, 98}, {739, 165}, {784, 286}, {826, 470}, {850, 618}, {871, 779}}; ts2 = {{683, 92}, {739, 174}, {785, 299}, {827, 489}, {851, 637}, {871, 807}}; tt = {ts1, ts2}; nlm = NonlinearModelFit[#, a Exp[b t];, {a, b}, t, ...


7

Easier by using ParametricNDSolve[]: params = {γ, a, b}; model = x /. ParametricNDSolve[{x''[t] + γ x'[t] + a x[t] + b x[t]^3 == 0, x[0] == 2, x'[0] == 0}, x, {t, 0, 20}, params]; fit = FindFit[data, model[Sequence @@ params][x], params, x, PrecisionGoal -> 4, AccuracyGoal -> 4] (* {γ -> 0.339787, a -> ...


5

Well, you have two questions in one: (1) How to "take" the curve from the image into Mma? and (2) How to fit it?. Here I address the first question and give one possible solution aditional to the ones offered before. Some time ago I published a function copyCurve on this site, along with its detailed description. You can take it from there. Copy the ...


4

The requirement that la + lc == 100 is simple to implement, just pass 100 - la to Fc, or use ModelP/.{lc->100-la} in the call to FindFit. For the other trouble, remember that N is a special function in Mathematica, so avoid ever using this as a variable. Using n instead, I tried ModelP = (2/q^4)*Re[((1 - Fc[q, lc, sc])*(1 - Fa[q, la, sa]))/ (1 - ...


3

Here is an approach using linear regression: circfit[data_] := Module[{reg, lm, bf, exp, center, rad}, reg = {2 #1, 2 #2, #2^2 + #1^2} & @@@ pts; lm = LinearModelFit[reg, {1, x, y}, {x, y}]; bf = lm["BestFitParameters"]; exp = (x - #2)^2 + (y - #3)^2 - #1 - #2^2 - #3^2 & @@ bf; {center, rad} = {{#2, #3}, Sqrt[#2^2 + #3^2 + #1]} & @@ ...


3

You may do it with Interpolation[] by expanding the list with a parameter value: l = {{0, 0}, {1, 0}, {.5, 1}, {-1, -2}, {1, 3}}; f = Interpolation[Table[{i, l[[i]]}, {i, Length@l}], InterpolationOrder -> #] & /@ {3, 4}; Row[ParametricPlot[f[[#]][t], {t, 1, Length@l}, Epilog -> {Red, PointSize[Medium], Point@l}, AspectRatio ...


3

Here's something to get you started, (assembled from Andy Ross' code). Data points are extracted from a data series in an image. Your original image will need some editing in order to process each curve separately. The following tadpoles plot is used for example. img = Import@"http://www.biologycorner.com/resources/graph_tadpoles.JPG"; data = ...


2

Try this: Show[{ ListPlot[Log10@data], Plot[Normal[H], {x, 23, 26}] }] Have fun!


2

In addition to correcting the syntax errors, having some approaching to starting values of parameters will help get desired fit, e.g. (using the definition from Nasser's correction of syntax errors and the data) Manipulate[ Plot[f /. s -> p, {L0, 20, 70}, Epilog -> Point@data], {p, 20, 40}] so fitting: nlm = NonlinearModelFit[data, {f, s > ...


1

Use the Check[] function to handle exceptions that throw messages. In detail, however, I would say that the problem is not well defined.


1

Only last line in Module can be used for output (I mean without ';'). So put semicolon after EACH line except last one, the Print command will work anyway. Then it will work - just tested


1

data = {{0, 1}, {1, 0.05}, {3, 2}, {5, 4}}; lm = LinearModelFit[data, x, x]; You can also use Transpose[{data[[All, 1]], lm["FitResiduals"]/data[[All, 2]]}] (* {{0, 0.791525}, {1, -16.9831}, {3, -0.140254}, {5, 0.0845339}} *) or Transpose[{First@#, lm["FitResiduals"]/Last@#} &@Transpose[data]] (* {{0, 0.791525}, {1, -16.9831}, {3, -0.140254}, {5, ...


1

syntax errors and not good choice of l as variable name as it looks like 1. Also need a constraint added to avoid complex values errors Clear[s, L0]; data = {{45.65, 38.9}, {66.87, 47.7}, {79.65, 63.4}, {36.03, 25.81}, {64.79, 71.99}}; f = (180/Pi)*ArcCos [-1 + (2*(s/L0)^0.5)*(Exp[-0.0001247 (L0 - s)^2])]; model = NonlinearModelFit[data, {f, s > 0}, ...


1

After fixing the many typos you have (what is log? Mathematica uses Log), and adding a constraint on k else complex solution will result, here it is data = {{0.617, 0.8}, {0.605, 0.6}, {0.5997, 0.4}, {0.5972, 0.2}, {0.5985, 0.1}}; soln = NonlinearModelFit[data, {y - 2478.82*w Log[k c + 1], k > 0}, {y, w, k}, c, MaxIterations -> 1000] There ...



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