Hot answers tagged

10

Deploy @ DynamicModule[{list = {}, fits = {}}, Panel @ Row[{Framed @ EventHandler[Dynamic[Graphics[{Thick, Blue, Line[list], PointSize[Medium], Red, Point[list]}, PlotRange -> 1, ImageSize -> Medium]], {"MouseDown" :> (list = {}; fits = {};), "MouseDragged" :> (AppendTo[list, MousePosition["Graphics"]]), "MouseUp"...


8

A curve that is a multiple of a gamma distribution seems to fit: r0 = Max[data[[All, 1]]] + 0.0001; nlm = NonlinearModelFit[data, r1 E^(-((r0 - x)/r2)) r2^-r3 (r0 - x)^(-1 + r3), {{r1, 0.004}, {r2, 6}, {r3, 1}}, x] Show[ListPlot[data, PlotStyle -> {{Yellow, PointSize[0.02]}}], Plot[nlm[x], {x, 60, 90}, PlotStyle -> {{Thin, Red}}]] area = ...


8

You are fitting a curve that has a shape of a known probability distribution and NOT fitting a probability distribution. This is a regression. After throwing out the complex numbers (as suggested by @BobHanlon) and throwing out the negative response values, one can use NonlinearModelFit. Fitting the log of the curve is more numerically stable when using ...


7

This does standard fit using Polynomial. You can add more terms to the polynomial and remove term. Can add/remove points. Each point added must be in increasing $x$ order. Usese LocatorPane to collect points and update the fitting Polynomial as more points are added. Manipulate[ (*Version 1.0 alpha *) tick; term = Table[x^n, {n, 0, terms - 1}]; fit =...


5

Not a full answer, but a hint. You can get analytical solution for integrals with assumptions (fill in your special needs). This should be more easy to handle. rhoA[A_, Rs_][r_] = (A 10^-3) r^(-1) (r + Rs)^(-2) Rs^(3); Sig[A_, Rs_][r_] = 4 r Integrate[rhoA[A, Rs][u r] u^2, {u, 0, 1}, Assumptions -> 0 < A < 2 && 0 < Rs < 3 &&...


5

When I have very little experience with a software function, I find it incumbent on me to figure out what I'm probably doing wrong rather than blaming the software function. (I've learned that the hard way.) The model presented with 3 parameters ($c$, $l$, and $r$) to fit is $$-\tan ^{-1}\left(\frac{\frac{1}{2 \pi c f}-2 \pi f l}{r}\right)=-\tan ^{-1}\...


4

Here is an approach based on generating a Line object, determining the total distance from all points in your dataset to the line, and minimizing that distance. In the following, price is obtained from your data, similar to what you described in your code: price = Import["data_out.txt", "CSV"][[4533 ;; 4922, 5]]; price = Transpose@{Range[Length[price]], ...


4

I suspect you must have used a different function when you found an acceptable fit with Python. Here is your data OCR'd from your previous question: data = {{6.806883, -4.95593692818423 Exp[-41]}, {6.813879, 0.2966197}, {6.81548, 0.2090413}, {6.815993, 0.1047412}, {6.816116, 0.2172217}, {6.816141, 0.0175237}, {6.816558, 0.0401401}, {6.820772, 0....


4

Try to tweak your initial guesses in the NonlinearModelFit to help the fit: mod = NonlinearModelFit[data, c*Sin[a*x + b], {{a, 300}, b, {c, 3}}, x] Show[ListLinePlot[data], Plot[mod[x], {x, -.1, .1}, PlotStyle -> Red]] I'm not very familiar with FindFormula, but you can use that as well: ff[x_] = FindFormula[data, x, TargetFunctions -> {Sin, ...


3

It looks like this question can be answered following the answers in this discussion: "Multi-peak fitting for peak position". I was too lazy to figure out a basis with the functions you want to fit. (You have listed many parameters.) So, I used the Gaussian function in this answer: gaussian[amp_, pos_, fwhm_, x_] := 2^(-((4 (-pos + x)^2)/fwhm^2)) amp Here ...


3

The reason you are receiving the "Data point {x1,y1} contains abscissa x1, which is not a real number" error is that Interpolation expects a numerical value for the abscissa. In the first example for the end points you used 1 and 390. This worked fine. In the second example you used, in addition, x1. That was what Interpolation was complaining about. It ...


3

You can't get there from here. You can estimate k (which equals kref Exp[(-e/8.314) ((1/360.15) - (1/353.15))] but there is an infinite set of kref:e pairs that give you the exact same prediction equation. Consider the results from dhnematicmax = 1.2 k = kref Exp[(-e/8.314) ((1/360.15) - (1/353.15))] nlm = NonlinearModelFit[data, (1 - Exp[-k*((t)^n)])*...


2

Higher precision is not needed. One just needs to scale the data so that numerical instabilities don't occur. This is especially the case here where the scales of the predictor and response variables are so far apart. For both models multiplying the predictor and response by appropriate constants don't change the underlying model. (Sometimes subtracting ...


2

To even attempt a fitting, one should consider a long list of caveats regarding the noisiness of your data, how you define your peak and what its functional shape should be, what you expect to be your baseline, etc. Nevertheless, you could try the following, with caution. The peak is around 85ish, so select a region in the data that has a reasonably flat ...


2

Here is a function you can apply to your dataset, specifying the areas you want integrated. The function will: select the relevant portion of your dataset take the first and last points in that region to establish a linear baseline by linear interpolation describe the data in between the specified boundaries by interpolation (no point in fitting, the shape ...


1

I am not a physicist but the need (craving? compulsion?) for the area under a parametric curve when there's such a poor fit makes no sense. Your data is pretty dense (lots of observations uniformly spaced) so why not pick a reasonable baseline (another concept I don't understand as the left and right side of the peaks seem to have different levels) and then ...


1

Using pretty much the same code from my answer to your last question: fit = NonlinearModelFit[ data, height1 Exp[-(x - peakposition1)^2/peakwidth1^2] + height2 Exp[-(x - peakposition2)^2/peakwidth2^2] + baseline, { {height1, 0.5}, {peakposition1, 76}, {peakwidth1, 2}, {height2, 1.3}, {...


1

Do the summation on your data before modeling, then fit to a simpler model: FindFit[ {#1, Plus @@ #2, #3}& @@@ {{1, {0, 1}, 3}, {2, {1, 1}, 6}, {3, {1, 0, 1}, 8}}, c1 x + c2 y, {c1, c2}, {x, y} ] {* Out: {c1 -> 2., c2 -> 1.} *) In passing, I would also recommend that you upgrade to LinearModelFit or NonlinearModelFit for your data ...


1

The documentation about variance structures in NonlinearModelFit is not in standard terms (at least in terms familiar to me, a statistician). When one uses the options Weights -> 1/errors^2, VarianceEstimatorFunction -> (1 &), the following model is assumed: $$y=f(x) + e \epsilon$$ where $y$ is the response, $f(x)$ is the nonlinear function of $...


1

I think the issue is that Mathematica is trying to take derivatives of your fitting form, but your fitting form involves NIntegrate, a numerical process. One thing you should be able to do for now to get around this is specify the fitting to use the "NMinimize" method. This method will not try to find gradients of the form you are trying to fit to. FindFit[....


1

Only a little more work is necessary to display the parameters you want for your Langmuir isotherms. This relies on the fact that the FittedModel[] object produced by LinearModelFit[] can also be used to extract the fitted parameters of the line (the "BestFitParameters" property) and the coefficient of determination $R^2$ (the "RSquared" property). To keep ...


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