New answers tagged

3

Clear["Global`*"] dataset = {{0., 0.0518175}, {1., 0.0306299}, {1.9, 0.610295}, {2., 1.32653}, {2.2, 4.01183}, {2.5, 6.37931}, {3., 6.50091}, {5., 6.54052}, {6., 6.57276}, {8.2, 6.59119}, {15., 6.56125}, {20., 6.5267}, {30., 6.4484}, {45., 6.2987}, {60., 6.11953}, {75., 5.84962}, {90., 5.43738}, {100., 4.96757}, {105., 4.54382},...


1

There are several (non-Mathematica) issues. You only have 8 data points to estimate 5 parameters (a1, a2, x0, p, and the error variance). The model is essentially overparameterized. Changing the model to allow for x = 0 and adding in MaxIterations->1000 gets a "result": xydata = {{1000, 18}, {750, 65}, {500, 67}, {200, 101}, {100, 88}, {50, 91}...


3

The problem is that with the available data and proposed model there are no finite values of the two parameters ($c_1$ and $c_2$) that can minimize the sum of squares (which is essentially what NonlinearModelFit uses in this case). In this case lack of numerical precision is not the culprit (although it is one of the usual suspects in many cases). The "...


1

Here's one approach that involves post-collection background correction. (* Create background, arbitrary removal of peak *) bg = Interpolation[Select[data, Not[2.3 < #[[1]] < 2.6] &], InterpolationOrder -> 2]; (* Create background correction function *) bgcorr[pt_] := {First@pt, Last@pt - bg[First@pt]} (* Create background corrected dataset *...


1

$Version (* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *) Clear["Global`*"] test3 = {0.329727, 2.58106, 3.13688, 4.75399, 6.64089, 9.73916, 11.7021, 14.4481, 16.3523, 14.6448, 14.1997, 16.8602, 18.1041, 17.6997, 15.804, 13.9181, 12.5242, 10.8824, 8.61049, 4.43998, 2.78258, 0.329727}; b = Exp[-(a - 9)^2/8]; c = Exp[-...


3

I hope that your real data consists of more than 3 data points when fitting a function with 3 parameters (a, b, and an error variance). While I don't know why the functions hang, for your function there is a simple fix. Because myfunc[x, 4] does not change with the scaling parameter, just replace the predictor with the values of the function. Then both ...


3

With a simple rational model together with Method -> "NMinimize" (no need for starting values!) the approximation is quite well! Try nlm = NonlinearModelFit[Tgexpandlit, {a + b/(1 + c T)}, {a, b, c}, T,Method -> "NMinimize"] Show[{ListPlot[Tgexpandlit], Plot[nlm[T], {T, 50, 110}]},PlotRange -> All]


8

It appears that you have 9 different sets of data probably all under slightly different conditions. You really need to account for that. If you explained that here, you might get an appropriate solution. Otherwise, you might try CrossValidated and ask about nonlinear mixed models (along with how the data was collected). In the meantime I'll just expand on ...


1

We can simply add any constraint in the second argument of NonlinearModelFit: ClearAll[a, b, model] model[x_] := a + b x; Unconstrained model: nlmf0 = Normal @ NonlinearModelFit[data, model[x], {a, b}, x] 102.167 - 4.21667 x Force the fit to go through {0, 100}: nlmf1 = Normal @ NonlinearModelFit[data, {model[x], model[0] == 100}, {a, b}, x] 100. - 4.05 ...


3

I suspect that you need to have the same values of the parameters for both the real and imaginary parts. If the variances associated with the real and imaginary regressions are the same and the random errors are independent, then consider using MultiNonlinearModelFit. If the variances are not known to be equal or the random errors are not independent, then ...


6

Can you use model fitting that is done separately for the real and imaginary parts? Example is given below. Separate fitting of real and imaginary parts Fit for the real parts: e0 = 8.854*10^-12; modelfitRe = NonlinearModelFit[Re /@ dataset, Re[eInf + (e1 - eInf)/(1 + I*2*\[Pi]*f*t1) + \[Sigma]/(I*2*\[Pi]*f*e0)], {{e1, 78.88}, {eInf, 5.2}, {t1, 0.008}, {\[...


4

We first get the picture and change it into an array of 0 and 1's.: pic = Binarize@Import["https://i.stack.imgur.com/K8u7A.png"]; dat = ImageData[pic]; We then approximately determine by inspection point 1 and 2 by: {p1, p2} = {{120, 403}, {400, 625}}; Of course you may play with this and determine more accurate points. To make the arithmetic ...


5

You could use a Karhunen Loeve Decomposition to get the rotation matrix like in C.E's answer: img = Import["https://i.stack.imgur.com/K8u7A.png"]; pts = ImageValuePositions[img, 1, 0.99]; kld = KarhunenLoeveDecomposition[Transpose[pts], Standardized -> True]; (* kld[[2]] contains the orthonormal rotation matrix *) With[{vecs = kld[[2]]}, With[...


5

There are some ways, outlined in posts that I linked to in a comment, to get pixels along a line in a given image, notably Brenseham's algorithm. Since you are looking to analyze a rectangular segment around a line I think, however, that rotating the image may be the way to go. Consider two points that form a line as follows: img = Binarize@Import["...


8

As noted in the OP, "PenaltyFunction" has the form pf[..., step] where the first argument is constructed from the constraint. When minimizing an objective function of the form obj[x,..], the actual penalty function is a scaled sum of penalties constructed from pf[] and the constraints: Max[1, Abs[obj[x,..]]] * ( (* the objective function ...


1

I different version of the workflow from Vitaliy's answer using both Quantile Regression and Least Squares fits. Note that the de-trending results are slightly different. Get the QRMon package: Import["https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/MonadicProgramming/MonadicQuantileRegression.m"] Get data: data = ...


3

Removing linear trend, as suggested in comments, is almost a one-liner (check out, Fit, FindFit, LinearModelFit): data=Import["https://pastebin.com/raw/aWYk1Jba"]; lm=LinearModelFit[data,x,x]; ListLinePlot[Transpose[{data[[All,1]],lm["FitResiduals"]}], PlotLabel->lm["BestFit"],PlotTheme->"Detailed"]


2

"An estimate without an associated measure of precision is at best of unknown value." -- Me If your data generation process results in two connected line segments, you might consider piecewise linear regression. Doing so will give you an estimate of precision of the value of the value of $x$ that results in a prediction of zero for the rightmost ...


0

fit5[x_] := Fit[data5, {1, x}, x] Solve[fit5[x] == 0, x] {{x -> -0.628349}} fit45[x_] := Fit[data45, {1, x}, x] Solve[fit45[x] == 0, x] {{x -> -1.35754}} Show[ListPlot[data5, Axes -> True, AxesOrigin -> {0, 0}, PlotRangePadding -> Scaled[.1], PlotRange -> All, PlotMarkers -> {Automatic, Offset[13]}, Frame -> ...


8

The equation you show will never fit your data because it cannot reproduce the asymptotic behavior at negative logt. You need to add a constant vertical offset for it do so: nlm = NonlinearModelFit[ hey, {deltaHinf (1 - E^-(10^logt/tau0)^beta) + const, beta <= 1}, {{deltaHinf, 2.2}, {beta, 0.6}, {tau0, 200}, {const, 0.2}}, logt ]; Show[ Plot[...


3

Clear["Global`*"] data = {{-2., 0.147789}, {-1.52288, 0.237749}, {-1., 0.476084}, {-0.522879, 0.641128}, {-4.82164*10^-17, 1.04976}, {0.477121, 1.43399}, {1., 1.77276}, {1.47712, 2.23469}, {2., 2.46328}, {2.47712, 2.85828}, {3., 2.96392}, {3.47712, 2.91354}, {4., 3.02119}}; {logtmin, logtmax} = MinMax[data[[All, 1]]] (* {-2., ...


Top 50 recent answers are included