New answers tagged

0

I am going to give an answer from my hunch. Say your function is 0.3 y + 2/x!. To fit this function you can use Gamma[x] instead of x!. The result would not be very good as the interpolation will go over non integer values as well. data = Flatten[Table[{x, y, .3 y + 2/x!}, {x, 0, 10}, {y, 0, 10}], 1]; f = a /Gamma[x] + b y FindFit[data, f, {a, b}, {x, y}] ...


0

I found a way to do it, it works fine: Manipulate[ Show[ListLinePlot[vexit[[i ;; j]], PlotStyle -> Green], Plot[Evaluate@Fit[vexit[[i ;; j]], {x^(-6)}, x], {x, vexit[[i, 1]], vexit[[j, 1]]}], Frame -> True], {i, 20, 40, 1}, {j, 45, 25, 1}]


2

Import takes all sheets, which nests the data. First@ takes the first sheet formatting the data you need for the subsequent expressions. test = First@Import["Velocidade Angular.xls"]; time = test[[All, 1]]; x = test[[All, 2]]; f = Interpolation[Transpose[{time, x}], InterpolationOrder -> 3]; Show[ ListPlot[test[[All, 1 ;; 2]], PlotStyle -> Red], ...


2

Thanks Young for the answers, The problem was simple , there was a slight modification in the equation, which is give below i[f_] := A - (x y - 4 (f - f0)^2)/(4 (f - f0)^2 + y^2); r[f_] := B + (2*(f - f0) (x + y))/((4 (f - f0)^2 + y^2)); and as Evans mentioned, the Parametric plot will be the following


1

Fit your data to a CDF using NonlinearModelFit data = {{406.833, 0.05}, {423.458, 0.1}, {436.375, 0.15}, {448.042, 0.2}, {459.583, 0.25}, {467.75, 0.3}, {479.083, 0.35}, {489.917, 0.4}, {500.875, 0.45}, {508.542, 0.5}, {521.792, 0.55}, {536.75, 0.6}, {547.458, 0.65}, {560.667, 0.7}, {584.208, 0.75}, {598.583, 0.8}, {632.875, 0.85}, {672....


3

You can make an interpolating function for both px and py from the data you have: data = Import["Downloads/lyap_4d.dat", "Table"]; d00 = data[[All, {1, 2}]]; pyfunc = Interpolation[{{#1, #2}, #4} & @@@ data, InterpolationOrder -> 1]; pxfunc = Interpolation[{{#1, #2}, #3} & @@@ data, InterpolationOrder -> 1]; That answers the question ...


5

I had the same idea as Jim Baldwin, as constraints are often implemented as penalty functions. Here is one that severely penalized any negative residual. The parameter scale might need to be adjusted to be a significant fraction of the range of the data values. ClearAll[penalty]; penalty[residuals_?VectorQ, scale_: 10] := scale*Length@residuals*(1 - ...


1

This is an illustrated comment to Young's answer, but you can plot in the Re/Im plane using the following: Show[ ListPlot[ Transpose@{Last /@ da1, Last /@ da2} , Joined -> True , AxesLabel -> {"Re", "Im"} ] , ParametricPlot[ {nlm[1, f], nlm[2, f]} , {f, Min@(First /@ da1), Max@(First /@ da1)} , PlotStyle -> Red ] , PlotRange -&...


4

So, I think this is what you actually wanted: d2 = {{{0.5, 0.0142}, {2.5, 0.00223}, {7., 0.00158}, {12., 0.00151}, {17., 0.0035}, {22., 0.0054}, {27., 0.00751}, {32., 0.01028}, {37., 0.01604}, {42., 0.02347}, {47., 0.03576}, {52., 0.05677}, {57., 0.07494}, {62., 0.11366}, {67., 0.16382}, {72., 0.23114}, {77., 0.32861}, {82., 0.44569},...


4

Updated with new model equations from OP Simultaneous NonlinearModelFit[] da1 = Transpose[{data[[All, 1]], data[[All, 2]]*Cos[data[[All, 3]]]}]; da2 = Transpose[{data[[All, 1]], (data[[All, 2]]*Sin[data[[All, 3]]])}]; r[f_] := A - (x y - 4 (f - f0)^2)/(4 (f - f0)^2 + y^2); i[f_] := B + (2*(f - f0) (x + y))/((4 (f - f0)^2 + y^2)); Clear[A, B, x, y, f, f0, ...


2

here is how to do with NMinimize, using @youngs comp model[x_] = a + b/(1 + I x c) s = NMinimize[ { Total[Norm[model[#[[1]]] - #[[2]]]^2 & /@ comp ], c < 0}, {a, b, c}] {5.35012, {a -> 4.63194, b -> 4.38458, c -> -9.15063*10^-6}} Show[{ ListPlot[{re, im}], Plot[ReIm[model[x] /. s[[2]]], {x, 0, 5.0119*10^6}, PlotRange ->...


3

The e in the non-linear fit should be Exp[] or it needs to be a variable x = Clip[r[t], {0, 1}]; y = Clip[rpp[t], {0, 1}]; tdata = NDSolve[{r'[t] == -L1*rpp[t] + c, rpp'[t] == L2*rpp[t] (1 - (rpp[t]/(r[t] + rpp[t]))) + L3*r[t], r[0] == 1, rpp[0] == 0} /. {L1 -> 0.5, c -> 0.001, L2 -> 0.91, L3 -> 0.05}, {r[t], rpp[t]}, {t, 0, 10}...


6

Create the list b as you have shown. nst[n_] := Length[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]] b = With[{stps = Array[nst, nn]}, Table[Max[Take[stps, n]], {n, nn}]]; It looks like ListPlot[b, PlotStyle -> Blue] It is apparent that we want to locate the first point in each group of horizontal points and use that in the ...


3

My attempt: (I re-labeled re to real and im to imag) comp = Transpose[{real[[All, 1]], real[[All, 2]] + I imag[[All, 2]]}]; Clear[a, b, c] c = -7*^-6; model = a + b/(1 + I x c); fit = NonlinearModelFit[comp, model, {a, b}, x] Show[ ListPlot[{real, imag}], Plot[{Re[fit[x]], Im[fit[x]]}, {x, 0, 3*^6}, PlotRange -> All] ] I hope this helps!


3

In such cases you can provide an initial guess. You can get an idea of the value from the other set. For example FindFit[Table[{p436UIe[[1]][[i]], p436UIe[[2]][[i]]}, {i, 1, 4}], a*(Exp[(x - b)/c] - 1), {a, b, c}, x] {a -> 62.2442, b -> -1.3725, c -> 0.219432} Which you know gives correct result. For the other set it is FindFit[...


3

As often when things go wrong, this is a question of initial values. Plugging in the approximate parameter values from f436 gives us: f436["BestFitParameters"] {a -> 62.2442, b -> -1.3725, c -> 0.219432} f436Gitter = NonlinearModelFit[ Table[{p436GitterUIe[[1]][[i]], p436GitterUIe[[2]][[i]]}, {i, 1, 4}], a*(Exp[(x - b)/c] - 1), {{a, 60}, {...


5

I extracted the data from the image using "Recovering data points from an image". ListPlot[extractedData, PlotRange -> All, PlotTheme -> "Detailed"] Then I applied NonLinearModelFit over that data for a list of sinusoids (and a constant): baseFuncs = Prepend[Table[Sin[k x Pi/5.25], {k, 1, 30}], 1]; vars = Array[a, Length[baseFuncs]]; nf = ...


2

There are lots of ways. Here's one for performing a two-sided test of the slope equaling $c$ by getting the P-value: data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}}; lm = LinearModelFit[data, x, x]; slopeInfo = lm["ParameterTableEntries"][[2]]; df = lm["ANOVATableDegreesOfFreedom"][[2]]; c = 2; testStatistic = (slopeInfo[[1]] - c)/slopeInfo[[2]]; pValue = CDF[...


2

Your function is the sum of two functions of a similar form. The single function that covers both is f[En_?NumberQ, a_?NumberQ, T_?NumberQ] := NIntegrate[(a e^3 x^2)/(500000000000 c^2 (-1 + E^((e x)/(1000000 k T))) h^2), {x, En, ∞}] I also scaled the parameters to be of similar size (and used essentially your estimated values for the starting values)...


3

This is not an answer, but an extended comment. Quite frankly, what you encountered is not (yet) a Mathematica-related problem: instead, you either have very poor starting points for your fitting, or a bad model altogether. You really MUST produce more reasonable starting values for your parameters. After all, you chose a very specific functional form, so ...


3

Usually we'll tend to fit linear system, and in this situaiton, add Log to data's y-axis will help: Log[a E^(b x)]=Log[a]+b x Truely, after this transformation, the points lay on a line~ great for fitting! It seems that this method could really do the work, so naturally, here comes the following code for fitting using normal linear fitting method: ldata ...


0

FindFit seems to work f[a_, b_, x_] = a*Exp[b*x]; expmodel[x_] = f[a, b, x] /. FindFit[data,f[a, b, x],{a, b},x] 50.3816 E^(-167.73 x) I will compare it with f1[x_]=E^(-0.08885264746563443` - 717.0097150284254` x) which can be found from Wjx's method. Show[{ListPlot[data, PlotRange->All], Plot[{expmodel[x],f1[x]}, {x, -0.01, 0.01}]}] Show[{...


3

I think you should work with the available options. And see How to | Fit Models with Measurement Errors. Set up and have some Data (see Error bars from lists @MarcoB): Needs["ErrorBarPlots`"] data = Table[{x, 2 x + 3 + RandomReal[{-0.5, 0.5}], RandomReal[{0.3, 0.5}]}, {x, -2, 2, 0.2}]; data2 = Table[{x, 2 x + 5 + RandomReal[{-0.5, 0.5}], RandomReal[{0.3, ...


3

I think I know what you want and here is the code: {{xmin, xmax}, {ymin, ymax}} =MinMax /@ Transpose[l1~Join~l2]; f1 = Interpolation@l1; f2 = Interpolation@l2; {crmin, crmax} = x /. FindRoot[#[x] == 0, {x, 1}] & /@ {f1, f2}; Needs["ErrorBarPlots`"] Show[ErrorListPlot[{withErrorl1, withErrorl2}, Prolog -> {Opacity@.3, Red, Rectangle[{xmin, ymin}, {...


0

THX for precious directed to... I modify for this: curve = NonlinearModelFit[data, y0 + a*Tanh[(t - x0)/b],{a,b,x0,y0}, t]; Show[ListPlot[data], Plot[curve[t], {t, -70, 10}]] curve FittedModel[123.929+106.55 Tanh[<<21>>(<<18>>+t)]] curve["BestFitParameters"] I had received: {a -> 106.55, b -> 23.1277, x0 -> -33....


2

ClearAll[a, b, c] data = {0.647888, 0.522495, 0.454224, 0.417054, 0.396816, 0.385798, 0.379799, 0.376532, 0.374754, 0.373786, 0.373259, 0.372972}; nlm = NonlinearModelFit[data, a + b/ c^x, {a, b, c}, x]; Normal@nlm $0.372629\, +0.505569 \,\, 1.8367^{-x}$ Limit[Normal[nlm], x -> Infinity] 0.372629


6

Start here to see what statistics functionality is available: http://reference.wolfram.com/language/guide/Statistics.html http://reference.wolfram.com/language/guide/ProbabilityAndStatistics.html Fitting is done with EstimatedDistribution or FindDistributionParameters. You want to fit a ParetoDistribution for continuous data or a ZipfDistribution for ...


6

As J.M. suggests, NonlinearModelFit is your friend. Using the data you have and the starting values given: curve = NonlinearModelFit[data, y0 + a*x0*Tanh[(t - x0)/b], {{x0, -33}, {y0, 126}, {a, 115}, {b, 25.5}}, t]; Show[ListPlot[data], Plot[curve[t], {t, -70, 10}]] You can find the converged values of the fit by curve


3

Another follow up, specifically to @Jim Baldwin's comment. Instead of plotting the full curve, we can also plot a certain number of points and see how they vary with the parameter t, i.e.: Clear[v] th = Array[v, Length[trainComposed[[1]]] - 1]; lwrPlot = Manipulate[ Show[listPlot, With[{x = #}, With[{bounds = Values@NMinimize[ ...


3

Just a follow-up to @J.M.'s answer to show the effect of the value of t: trainX = {100, 320, 213, 512, 58, 84, 113, 142, 93, 121, 421, 432, 249, 254}; trainY = {140000, 400000, 241000, 489000, 78000, 123000, 139000, 143000, 97000, 134000, 392000, 458000, 311000, 378000}; rX = MinMax[trainX]; rY = MinMax[trainY]; Manipulate[ (* Make a table of ...


8

In part, your trouble stemmed from an attempt to determine exact/symbolic results from your data. Even for this modestly-sized set, the objective function you were feeding to Minimize[] is already sufficiently complicated, which is why it takes long. As I previously noted, using NMinimize[] instead will give you the numerical values you need. Less ...


1

Mathematica's HyperbolicDistribution[λ,α,β,δ,μ] is the generalized hyperbolic distribution. When λ = -1/2, it is the NIG distribution. So it can be used directly with FindDistributionParameters or EstimatedDistribution to fit a NIG to data, and then check the fit by DistributionFitTest.


0

One could also estimate the sum-of-squared residuals (or any other diagnostic, statistical property etc.) directly within Sow Reap@NonlinearModelFit[data, Exp[a x/(b + c x)], {a, b, c}, x, Method -> {NMinimize,StepMonitor :> Sow[Sum[(data[[i,2]]-Exp[a data[[i,1]]/(b+c data[[i,1]])])^2, {i,1,Length[data]}]],Method->{"...


8

EvaluationMonitor is going to be called whenever the objective function is being evaluated, that is much more often than StepMonitor. The reason for not getting any points back is that the StepMonitor specification is not propagated to the NMinimize call. Try the following syntax instead nlm = Reap @ NonlinearModelFit[data, Exp[a x/(b + c x)], {a, b, c}, x,...


2

The import has imported the single sheet in the "xlsx" file.In the following data was the copied and pasted information in the question (deleting \). It can be used for data analysis and visualization after some processing: datm1 = data[[1,11 ;;]];(* take first sheet and remove leading empty cells*) datm2 = StringSplit[#] & @@@ datm;(*split string at ...


1

So while I can't see your data to make sense, in principle this should work: data = {{1., 0.75}, {2., 0.89}, {3., 0.42}, {4., 0.99}, {5.,0.84}, {6., 0.34}, {7., 0.83}, {8., 0.93}, {9., 0.76}, {10.,0.11}}; lm = LogitModelFit[ data, x, x ]; lm[11] 0.50088


2

One quick approximation uses the compound median filter defined here. I converted the blue line in your image to a vector of amplitudes trace. The orange line is the filtered output, the green line is the residual. Vary the second input parameter of CompoundMedianFilter to see other baseline approximations. ListLinePlot[{trace, CompoundMedianFilter[trace, ...



Top 50 recent answers are included