Tag Info

New answers tagged

2

Try the following. These are two models: one is with a single Gaussian and the second is with two ones accounting for the shoulders along with the corresponding fittings. model1 = a*Exp[-b*(x - c)^2]; model2 = a*Exp[-b*(x - c)^2] + d*Exp[-e*(x - c)^2]; ff1 = FindFit[data, model1, {a, b, {c, 14}}, x]; ff2 = FindFit[data, model2, {a, b, {c, 14}, d, e}, x]; ...


1

No, it is not possible. With code converted to a LibraryLink library by way of Compile you are limited to using functions that either can be expressed directly in C, or exist in the runtime library; unfortunately, FindFit is not included in either category. When present in code passed to Compile, FindFit results in a call back to the top level, and it is ...


0

Probably the easiest way is to use Interpolation to create a function from your tabled data.


3

Here is an initial approach that needs someone to generalize and clean up (please). I am going to fit an interpolation function to the data. The interpolation points will be adjusted to make a best fit. First we make some data SeedRandom[12345]; data = Table[{x, Sin[2 \[Pi] x] + 0.1 RandomReal[]}, {x, 0, 0.8,0.02}]; Now we define the x locations which we ...


1

I believe I understand your question. Here is a table of values of {alpha, f[alpha]} mybasedata = Table[{α, x /. NSolve[{x == Cos[α x] && 0 < x < 2 π/α}, x][[1]]}, {α, 0.1, 2, .1}] // Quiet Here is the functional fit: myfit[α_] = Fit[mybasedata, {1, α, α^2, α^3}, α] (* 1.02718 - 0.2184 α - 0.112612 α^2 + 0.0475883 α^3 *) Here is the ...


1

Your problem is that you are using x as the variable to represent the explanators in your model, but you have already defined x to be the list of numbers at the top. Just change this line to be something other than x, like q: model = LinearModelFit[xy, q, q] And don't forget to make the matching change in the Plot command: Show[ListPlot[xy], ...


1

Edit (This task will not let me go ...) model3 = ((a + b*x + c*x^2)/(1 - a + b*x + c*x^2)); myFit = Normal[NonlinearModelFit[data, model3, {a, b, c}, x]] $\frac{3.79483 x^2-1.70736 x+0.664564}{3.79483 x^2-1.70736 x+0.335436}$ Just for fun: model2 = a*x^5 - b*x^4 - c*x^3 + d*x^2 - e*x + f; myFit = Normal[NonlinearModelFit[data, model2, {a, b, c, d, ...


3

First, let's create some data: dataZ = Table[RandomReal[{0.9, 1.1}]*Sin[x + y] + RandomReal[{-.1, .1}], {x, 0, 2, .1}, {y, 0, 2, .1}]; Now we can use MapIndexed in order to add the missing x and y values: dataYXZ = Flatten[MapIndexed[Append[2 (#2 - 1)/20, #1] &, dataZ, {2}], 1]; Notice that MapIndexed positions need to ...


1

Something like this could be shorter: loc[col_] := Graphics[{Darker[col, 0.5], Table[Circle[{0, 0}, i/2], {i, 3}], Table[Rotate[Line[{{0.1, 0.25}, {0.1, 1.75}}], t, {0, 0}], {t, 0 , 2 Pi, Pi/2}]}, ImageSize -> 20]; mod = a*(# + e)^2 + d &; data = Import["http://i.stack.imgur.com/SmQLj.png", ImageSize -> ...


1

Okay, I know it's strange to answer my own question, but I hope other people with similar problems will appreciate this: I found a way to have the same functionality that runs much much quicker, using Manipulate (which I wanted to avoid in the first attemot, because I thought DynamicModule would get faster results :) ) So here is the code that works fine for ...


5

Directly from the documentation of LinearModelFit X = {5, 10, 15, 20, 25, 30, 35} Y = {9.4, 18.3, 26.2, 36.3, 37.4, 47.3, 56.3} fit = LinearModelFit[data = Transpose@{X, Y}, {1, x}, x] (* FittedModel[1.49929 x+3.04286] *) Show[ListPlot[data], Plot[fit[x], {x, 0, 35}], Frame -> True] ListPlot[fit["FitResiduals"], Filling -> Axis] Note that ...


4

The fit given in this question, a + b t^2, is actually linear in a and b, so the regression line can be found with a linear fit, i.e. x = {1, 2, 3, 4}; y = {0.891, 0.885, 0.844, 0.836}; data1 = Transpose[{x, y}]; n1 = Normal@NonlinearModelFit[data1, a + b t^2, {a, b}, t]; n2 = Normal@LinearModelFit[data1, {1, t^2}, t]; n1 == n2 True The prediction ...



Top 50 recent answers are included