# Tag Info

15

Step 1: find the curve in the black and white image. For this, I will use a shortest path search, and to make sure it finds the path I'm looking for (instead of one of the short cuts through the labels), I will give it a few "path markers" along the way that the path should visit in order: First, load the image, get the black pixels: img = ...

12

I didn't get a good answer, but this is how I would do it and probably how I would evaluate the quality of an answer. Much of what I do below involves manual work, but it could be automated: First, we need some points along the curve. I selected them manually If I hadn't manually selected them, I would have used some image processing including a thinning ...

6

Looking at help page for LinearModelFit, Using VarianceEstimatorFunction->(1&) and Weights->{1/Δy_1^2,1/Δy_2^2,…}, Δy_i is treated as the known uncertainty of measurement y_i and parameter standard errors are effectively computed only from the weights. data = {{1, .9}, {1.5, 1.2}, {2., 1.5}, {2.5, 2.0}, {3., 2.6}}; errors = {.2, .2, .2, .2, ...

5

After looking at each of the 5 data sets, it does not appear at all that they might have residuals resulting from a single distribution (based on the estimates of mean square error). Why did you think they all had a common error distribution? Is there some theoretical or historical reason? As @AntonAntonov states, quantile regression can be more useful ...

4

datadamped = Import["http://comsics.usm.my/tlyoon/teaching/ZCE111_1516SEM2/data/\ data_A6Q2.dat", "Data"]; max = datadamped[[#]] &@FindPeaks[datadamped[[All, 2]], 0][[All, 1]] min = datadamped[[#]] &@FindPeaks[-datadamped[[All, 2]], 0][[All, 1]] This gives you list of maximums and minimums. If you need a fit you probably want to simplify the ...

3

I'm not aware any coding options for such constraints but you can roll your own. Here's an example with using two "treatments" with different Poisson means. (* Generate data from two Poisson distributions with very different sample sizes *) n1 = 1000; n2 = 10; λ1 = 5; λ2 = 15; SeedRandom[1234]; v1 = RandomVariate[PoissonDistribution[λ1], n1]; v2 = ...

3

If you restructure your datasets to have each row representing {x,t,y} with y as the response variable, it should be pretty straightforward. Here is an example with some simulated data. (* Define a function *) f[x_, t_, p1_, p2_] := p1 + Sin[x + t p2] (* Common parameters *) p1 = 0.2; p2 = 2; (* Data set 1 *) x1 = 1; data1 = Table[Flatten[{x1, t/100., ...

3

Warning: The result at the end is very anticlimactic. While you’ve stated that your model has an intercept of zero the model that @JasonB is assuming with the particular use of LinearModelFit is the following: $$y_i=a+b x_i+ϵ_i$$ with $ϵ_i\sim N(0.2^2)$. Besides having an intercept (potentially not equal to zero), this model assumes that there is only ...

3

I wouldn't be so quick to rule out rescaling your data or working in reduced units, since this works fine: data = {{0.0166667, 2.86927*10^-12}, {0.0333333, 1.12725*10^-11}}; k = 1.3806488*10^-23; T = 300; nlm = NonlinearModelFit[data, k*300/(m*10^-13)*t^2, {m}, t, Method -> "NMinimize"]; (* Gives m = 4.07829 *) I think the problem really lies with ...

2

This is not a real answer, but applying @JasonB's approach to 2D case. So x is a vector and a is a matrix. I simplified the function to see how good is the fit in simple case. We have noisy data and we want to try to find fit and compare it with test f[x_, a_] := Exp[-x.a.x]; test = {{0.75, 0.}, {0, 0.25}}; data = Flatten[{#, f[#, test] + ...

2

I've always done it like this, and I've done fits with a few hundred parameters so it isn't that much of a pain. The point is that you define the function f to take a vector input for x and a. Then you define a vector of variables, {x1, x2,....} and that is the fourth argument to NonlinearModelFit. The second argument to NonlinearModelFit needs to be a ...

2

I'm assuming the objective is to find "the best" set of models (all with a single common parameter) with potentially different models for each of many data sets. Using NonlinearModelFit one could fit a combined model with all data sets and a specific set of models. One would obtain the AIC value for each of the all possible specific sets of models (one ...

1

This model is linear in 1/m, hence use LinearModelFit lm = LinearModelFit[data, {k*300 t^2}, t, IncludeConstantBasis -> False] Then just invert the result: 1/lm["BestFitParameters"][[1]] that gives 4.07829*10^-13 If you give different weights to each point, you will find another result. The "best" result will be obtained with proper weighting.

1

Just a quick glance, you can try this though. I didn't have time to plot the residuals (or take a look at them for that matter...no pun intended) but it could be worth taking a look at. The function seems to predict your data points with relative accuracy.

1

Turns out the program was taking the six peaks on the right side of my graph and averaging them to find the constant I had asked it to look for. I solved this by removing the second half of my data, but I believe it could also be solved by adding more troughs in the equation to account for them. Thanks for the help!

1

This is an extended comment rather than an answer. I (crudely) digitized the data from about $x=600$ to $x=1000$ and gave initial estimates for what I would call the 6 troughs (rather than peaks) and your code seemed to work fine: fit6peakslorentz[data, {691, 728, 765, 791, 827, 864}] As @MarcoB suggested, making available the subset of the data you ...

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