Tag Info

Hot answers tagged

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 ...


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 ...


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 ...


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 ...


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, ...



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