Tag Info

New answers tagged

1

data = {{1, 1, 4}, {1, 3, 4}, {2, 1, 4}, {2, 3, 3}, {3, 7, 4}, {3, 3, 2}}; expr = a*x + b*y + c*x*y + d*y^2 + e; f[x_, y_] = expr /. FindFit[data, expr, {a, b, c, d, e}, {x, y}] // Rationalize // Simplify (1/4)*(17 - 2*x*(-1 + y) - 2*y + y^2) data[[All, 3]] == f @@@ data[[All, 1 ;; 2]] True For your second data set, ...


1

Perhaps this is enough for you: d1 = Transpose[{#[[1]] - #[[1, 1]], #[[2]]} &@ Transpose@Select[data, #[[2]] > 0 &]]; nlm = NonlinearModelFit[d1, c PDF[BetaDistribution[3, b], x], {b, c}, x]; Plot[nlm[x], {x, 0, .003}, PlotRange -> All, Epilog -> Point@d1] Another option: nlm = NonlinearModelFit[d1, c PDF[MoyalDistribution[.0002, b], ...


2

I am answering my own question after a suggestion by MichaelE2 Here is a second version of dfit (dfit4) which has Sliders and TrackedSymbols. The sliders are a method of finding appropriate initial conditions. The solution to the problem is to include TrackedSymbols in the Dynamic that calculates the NonLinearModelFit. ClearAll[dfit4]; dfit4[data_] := ...


2

First, some slight changes to orbita: orbita[a_?NumberQ, b_?NumberQ, c_?NumberQ, d_?NumberQ, e_?NumberQ] := (orbita[a, b, c, d, e] = {X[t], Y[t]} /. First@NDSolve[{Vx'[t] == (-e*G*X[t]*Msun)/(X[t]^2 + Y[t]^2)^(3/2), Vy'[t] == (-e*G*Y[t]*Msun)/(X[t]^2 + Y[t]^2)^(3/2), X'[t] == Vx[t], Y'[t] == Vy[t], Vx[0] == a, Vy[0] == b, ...


0

data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}, {6, 4}, {7, 5}}; nlm = NonlinearModelFit[data, Log[a + b x^2], {a, b}, x]; Using the Listable attribute, for any sort of list (of lists) of numbers: Function[Null, nlm[#], Listable][{1, 2, {3, 4}, {{5}, 6}}] (* {1.07591, 1.9757, {2.66328, 3.19161}, {{3.61536}, 3.96754}} *) Using Map: Map[nlm, {1, 2, {3, 4}, ...


4

On the borderline of comment and answer: I've found it helpful to read the error messages carefully. They contain important information specific to your problem. These are telling you that b x+a x^2+c[T] is not a number when a number is substituted for x. In particular, a and b are nonnumeric symbols. It's complicated why the symbol T is present -- it ...


4

You can use NonlinearModelFit instead of FindFit. dt = Table[Prime[x], {x, 20}]; FindFit[dt, a x Log[b + c x], {a, b, c}, x] (* {a -> 1.42076, b -> 1.65558, c -> 0.534645} *) nlm = NonlinearModelFit[dt, a x Log[b + c x], {a, b, c}, x]; Normal[nlm] (* 1.42076 x Log[1.65558+0.534645 x]*) nlm["ParameterTable"] Grid[Transpose[{#, nlm[#]} ...


4

Too long for a comment: ClearAll[x, y, a, b, c, T, z, data2, X] y[a_, b_, x_, T_] := a*x^2 + b*x + c[T]; c[T_?NumericQ] := Piecewise[{{0, T == 1}, {1, T == 2}, {-1, T == 3}, {Indeterminate, True}}]; z[X_?NumericQ, T_?NumericQ, a_?NumericQ, b_?NumericQ] := NIntegrate[y[a, b, x, T], {x, 0, X}]; data2 = {{0, 1, 0.0178038}, {1, 1, 1.34999}, {2, 1, 6.6659}, {3, ...


0

It seems this problem has been sufficiently answered, but I'd like to mention Stan Wagon's FindAllCrossings2D[].


0

@ Öskå : In the this graph you can see the Fourier transformation of a velocity signal of explosion. For a geological analysis I'm looking for the maximum frequency where the amplitude is at 25% corresponding at Fm in orange. For this I used the following code, very close to the code proposed by Michael E2 : FonctionInterpolee = ...


3

Well in the particular case of a BinormalDistribution there are plenty of tests available for the individual hypotheses. SeedRandom[124]; data = RandomVariate[BinormalDistribution[{1, 2}, {1/3, 4}, 3/4], 1000]; To test the mean vector.. LocationTest[data, {1, 2}] (* 0.174306 *) The variances can only be tested independently since there is no ...


1

This seems to come close. The idea is to find factors, at all levels, that are not numeric and are independent of the variable. Set up replacement rules for these in terms of some new symbol. Do the replacement. I also return the rules used in case that might be useful. replaceFactors[expr_, x_, c_Symbol] := Module[ {e2 = MapAll[Collect[#, x] &, ee], ...


2

With the functions given in the question above: Pressing the plus sign in the interpolation function object will expand the description to include the method. sol = NDSolve[eqs, {n, S}, {t, 0, 60*10^-9}, MaxSteps -> 10^6] The problem is not the iterator range but rather the initial number of PlotPoints. PlotPoints -> n specifies the total number ...


2

Your data: data = {{0.067, 0.423}, {0.30, 0.408}, {0.60, 0.433}, {0.25, 0.3512}, {0.37, 0.4602}, {0.44, 0.413}, {0.60, 0.390}, {0.73, 0.437}, {0.8, 0.47}}; errors = {0.055, 0.0552, 0.0662, 0.0583, 0.0378, 0.080, 0.063, 0.072, 0.08}; ErrorListPlot[Transpose[{data, ErrorBar /@ errors}], PlotRange -> {0, 1}] Assume that the errors are distributed ...


3

Before posting the solution I found, let me reformulate the problem and give more details about what I am trying to acheive. A Robotic arm grabs a turbine blade. All the robot positional data is available and the blade geometry as well. I need to find the exact position of the blade relative to the grabber, using positional information provided as a point ...


1

It is not clear to me what is the difference between FindFit and NonlinearModelFit. But NonlinearModelFit help says: And FindFit says In this case, they both indeed produce the same fit, hence both are doing least squares model = a + b/(c*x^2); nlm = NonlinearModelFit[data, model, {a, b, c}, x]; nlm["ParameterTable"] nml2 = FindFit[data, model, ...


1

Here is how I would do it. First, import the data using Import. This is straightforward from the documentation, using either Excel or txt files, so for the purposes of this exercise, I'm going to generate the data in Mathematica instead. myD = MixtureDistribution[{2, 1}, {NormalDistribution[2, 2], NormalDistribution[2, 1/2]}]; For reference, here is ...


0

Well I have done this in that way: calcMethod[randFN_, randfacdef_, samplerun_] := Module[{limit, vmaxmod, kmmod, yy0, xx, yy, data, datalb, dataeh, datahw, minxlb, maxxlb, minylb, maxylb, minx, miny, maxx, maxy, minxeh, minyeh, maxxeh, maxyeh, minxhw, maxxhw, minyhw, maxyhw, vmaxnl, kmnl, vmaxlb, kmlb, vmaxeh, kmeh, vmaxhw, kmhw, mmenten, eadieh, ...


2

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


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, ...



Top 50 recent answers are included