Tag Info

New answers tagged

4

I guess what you are looking for can be easily achieved (and adjusted) with the RegionFunction option. Let me give an example using Plot3D. It should work similarly with ListPlot3D: Manipulate[ Plot3D[Sin[10 x + 0.1 y]^2*Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2}, PlotRange -> {Automatic, Automatic, {0, 1}}, PlotPoints -> 25, RegionFunction ...


0

paramSol = ParametricNDSolve[{y1'[t] + y1[t]/t1 - f[t] == 0 , y1[0] == 0, y2'[t] + y2[t]/t2 - f[t] - a*y1[t] == 0 , y2[0] == 0}, {y1, y2}, {t, 0, 10}, {a, t1, t2}]; model = Evaluate[a1 y1[a, t1, t2][t] + a2 y2[a, t1, t2][t] /. paramSol]; nlm = NonlinearModelFit[data, model, {a, a1, a2, t1, t2}, t]


2

This may be useful.. sampledata = {#, Piecewise[ {{ 1 + # , # < 1} , { 6 (# - 1) + 2 , # > 1} }] (1 + RandomVariate[NormalDistribution[0, .2]])} & /@ RandomReal[{0, 2}, 50]; Manipulate[ fit = NonlinearModelFit[ sampledata , Piecewise[ {{ a + b x , x <= m } , { c (x - m) + a + b m ...


2

This is not really a Mathematica question, but here are some thoughts. I doubt you will be able to distinguish between a break in trend and a logarithmic trend. Take the log of the data and see if that has a linear trend instead. There are plenty of ways to test for and find a structural break. Have a look at some basic resources on this. The CUSUM test is ...


3

There is a problem with your initial velocity: Hmax = Vo^2*Sin[phi Degree]^2/(2*9.8) (*13.9274*) With that initial Velocity, you can only reach 13.9 meters (far from the 25+ from your data), and that's without drag. So you can't fit anything really. Maybe the velocity is not well measured. What you could do is fit Cdrag and Vo. Using part of Mariusz's ...


4

The calculation of AIC for a particular model varies among software programs and yet none of those are necessarily wrong. The difference among software programs (that do it correctly) is because some leave off constants that don't vary with the data. What counts is that the difference of the AIC values between two different models in the same software ...


1

OK, I'm able to give an incomplete answer now.I can't fit but.. Values for all constants are correct? You must have made ​​a mistake somewhere. Cdrag = 0.13952; g = 9.80665; M = 0.04593; R = 0.04267/2; Vo = 48.54; \[Phi] = 19.9; \[Rho] = 1.2041; A = \[Pi] R^2; k = 1/2 \[Rho] A Cdrag; {xsol, ysol} = NDSolveValue[{x''[t] == -(k/M)*(x'[t])^2, y''[t] == ...


1

In the format you propose, the dependence of $f$ on $t$ is left implicit in your model. $a(t)$ and $b(t)$ seem to be some quadratic function of $t$, but as @jens_bo mentioned, you need to tell us or find out more about $a(t)$ and $b(t)$ to obtain a fit of $f$ as a function of $t$. Data format: Data needs to be presented to all fitting functions as a list of ...


0

Note: You should check if the code I am using matches your problem, since I had to guess some unclear parts (parenthesis and x,y,z naming). Since I don't know anything about $a(t)$ and $b(t)$ I threat $f(t)$ as a function of two unknowns $a$ and $b$, or $f(a,b)$. If we want to fit the data we can use NonlinearFit, but NonlinearFit takes data of the form ...


0

If m is a known value, then the method of moments only requires the sample mean and sample variance to be equated to the mean and variance of the distribution (and one can have weights 1/2 by using w as the weight for the values of x < m: (* Weight *) w = 1/2 (* Mean *) mean = FullSimplify[ Integrate[w a x Exp[a (x - m)], {x, -Infinity, m}, ...


0

If n is a list containing the sample sizes (all elements equaling 50 in your case) for a binomial variable, then you can account for potentially varying sample sizes by including the Weight option in the following manner: Weights -> 1/Sqrt[n] This could be made much more explicit in the documentation. A more complete example might be model = ...


1

Like this? data = {{0.1, 2}, {0.12, 3}, {0.15, 4.2}, {0.17, 5}}; line = Fit[data, {1, x}, x]; Show[Plot[line, {x, 0, 0.2}], ListPlot[data]]


1

Having a closed form for integral of an incomplete gamma function should be a big deal(!), but having a numerical approximation is simple. Define: f[k_,e_,limit_]:=NIntegrate[Gamma[k, 0, Exp[-2 e x^2]], {x, -limit, limit}]; For example: f[2,0.2,3] (* 0.591563 *) You can also see how f changes with k and e: Plot[{Legended[f[k, 0.2, 3.], "e=0.2"], ...


2

To generate data using the given equation, you can use different values for {a,b,c} to generate data. Here's a method using With where {a,b,c} are local variables: f[x_, y_, z_] := With[{a = 0.1, b = -3., c = 1.2}, a *x^2 *Exp[b *x + y^2] + c* z^2* y]; Then you need to build you dataset; You can use Table and Flatten to have your data in suitable format ...


2

This is what I understand you're asking: For your problem the data matrix has to be of the form {{x,y,z,f},{...},...}. I will create some data. data = MapThread[{#1[[1]], #1[[2]], #1[[3]], 0.34*(#1[[1]]^2)*Exp[-1.82*#1[[1]] + #1[[2]]^2] + 0.94*(#1[[3]]^2)*#1[[2]] + #2} &, {RandomReal[1, {100, 3}], RandomReal[{-0.01, .01}, ...


0

I understand your question to mean that you want to fit only the "linear" portion of your dataset (i.e. really the exponential response in the original data), and you don't care for the rest saturation part of the response. On general principles I would suggest that you fit the data to a nonlinear exponential model, rather than to a linearized one. All ...


0

If you want a linear fit (for the log of current predicted by voltage) for part of the data and a log fit (for the log of current predicted by the log of voltage) for the rest of the data, you might consider a piecewise fit where one also estimates the join point. An example is already available at this site: fitting piecewise functions


6

Pure GammaDistribution does not seem at all like a good fit even visually. You need probably a MixtureDistribution. You could BTW skip NonlinearModelFit and start playing with FindDistributionParameters. But I think you are better of trying out latest WL function FindDistribution. In automated regime it finds almost what you need: dis = ...


1

Here's how to interpret statistical significance, here illustrated for a $\chi^2$ distribution: Such a distribution tells you the expected probability of finding a value of $x$ as the sum of squares of values chosen from $n$ univariate Gaussian distributions (where we call $n$ the degrees of freedom). Of course, the value of $x$ can never be negative. The ...


17

Luca, I think that you may be misunderstanding the meaning of "linear" in the names of those functions, and in general in reference to linear models. Just to make sure that we agree on the nomenclature here, in a fitting model you have parameters, and predictor variables. For instance, in a simple quadratic model such as y = a x^2 + b x + c we typically ...


0

Going through this solution, it looks like that function f in FindMinimum[f,x] should be declared to have numerical parameters. Ivan's answer indicated this too. Essentially, for the parametric function route to work, one needs: func[k1_, k2_, k3_] := Total[(ci - Through[pfun[k1, k2, k3][ti]])^2, 2] /; And @@ NumericQ /@ {k1, k2, k3}; ...


2

Define this function: f[k1_?NumericQ, k2_?NumericQ, k3_?NumericQ] := Sum[Total[(ci[[i, All]] - Map[pfun[k1, k2, k3][[i]], ti])^2], {i, 1, 3}] // Quiet Then, fit = NMinimize[f[k1, k2, k3], {k1, k2, k3}]; params = fit // Last (*{k1 -> 0.000194805, k2 -> 0.0291469, k3 -> 0.109229}*) Plot it, Table[Show[ ListPlot[Transpose[{ti, ci[[i]]}]], ...


3

I just wanted to point out that all the routes above will work if there is only one differential equation: data = NDSolveValue[{ x''[t] - k1*(1 - x[t]^2)*x'[t] + k2*x[t] == 0, x[0] == 2, x'[0] == 0} /. {k1 -> 1., k2 -> 1.}, Table[{t, x[t] + RandomReal[{-.3, .3}]}, {t, 0, 10, .2}], {t, 10}]; dataT = data\[Transpose]; ti = dataT[[1, ...


6

I am not sure what the exact aim is and time does not permit refining some loose ends. Assuming reason to believe data is ellipsoid (as test data is): Using test data from another answer: data = Flatten[ Table[{RandomReal[{1.9, 2.1}] Cos[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] Sin[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] ...


5

This is not very Mathematica style, but it will do the job. We start with a trial data set which is confined in an ellipsoid data = Flatten[ Table[ {RandomReal[{1.9, 2.1}] Cos[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] Sin[n/100 2 Pi] Sin[m/100 Pi], RandomReal[{0.9, 1.1}] Cos[m/100 Pi]}, {m, 100}, {n, 100}], 1]; ...


1

Here's sample data: testdata = {{2, 0, 0}, {-2, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 5}, {0, 0, -5}, {1, 1, 4}, {2, 4, -3}}; Here's the covariance matrix: myCov = Covariance[testdata]; Here's the solution (z value) for a best-fit ellipse: mysols = Solve[{x, y, z}.Transpose[myCov].myCov.{x, y, z} == 5, z] {{z -> (17119 x + 51177 y - 8 ...


0

Fit can be used for this purpose. Here is some data in three dimensions: data = {{0, 0, 0}, {1, 0, 1}, {0, 1, 2}, {1, 1, 0}, {1/2, 1/2, 1}}; Find the plane that best fits the data: plane = Fit[data, {1, x, y}, {x, y}] Show the plane with the data points: Show[Plot3D[plane, {x, 0, 1}, {y, 0, 1}, PlotStyle -> Opacity[.5], PlotRange -> {0, ...



Top 50 recent answers are included