Tag Info

New answers tagged

8

The general equation of ellipse (here) is given by: ellipse[x_, y_] = a x^2 + b x y + c y^2 + d x + e y + f == 0; solving using 5 pintos result in: SeedRandom[3]; pts = RandomReal[{-1, 1}, {5, 2}]; sol = Solve[ellipse @@@ pts]; ellipse[x, y] /. sol[[1]] // Simplify (*a (-0.275185 + 1. x^2 + x (0.189022 + 0.566953 y) + 0.1281 y + 0.397124 y^2) == ...


21

The following is based on the fact that the determinant of a matrix is equal to zero when two rows are the same. Thus, if you plug any of the points in, you get a true statement. SeedRandom[3]; pts = RandomReal[{-1, 1}, {5, 2}]; row[{x_, y_}] := {1, x, y, x*y, x^2, y^2}; eq = Det[Prepend[row /@ pts, row[{x, y}]]] == 0 (* Out: ...


2

Exporting the NonlinearModelFit result objects as mx seems to work fine. SetDirectory[NotebookDirectory[]]; ClearAll[dat0, nmf0, pcit0]; dat0 = Table[{x, (x + 3)/(x + 2) + RandomReal[{-0.01, 0.01}]}, {iSet, 1, 10, 1}, {x, 0, 5, 0.01}]; Dimensions@dat0 nmf0 = Table[NonlinearModelFit[dat0[[iSet]], (x + a1)/(x + a2), {a1, a2},x], {iSet, Length@dat0}]; ...


7

data = {{0., 100.}, {0.02, 81.87}, {0.04, 67.03}, {0.06, 54.88}, {0.08, 44.93}, {0.1, 36.76}}; model = a Exp[-k t]; fit = FindFit[data, model, {a, k}, t] {a -> 100.004, k -> 10.0033} fun = Function[{t}, Evaluate[model /. fit]] Plot[fun[t], {t, 0, 0.3}, Epilog -> {PointSize[0.02], Red, Point[data]}, PlotRange -> All, PlotTheme -> ...


7

Check out the formula for capacitor discharge, it takes the form chargeDecay=initialCharge Exp[- r/c t] So t = {0, 0.02, 0.04, 0.06, 0.08, .1}; q = {100, 81.87, 67.03, 54.88, 44.93, 36.76}; modelData = Transpose[{t, q}]; soln=FindFit[modelData, a Exp[-b x], {a, b}, x] (*{a -> 100.004, b -> 10.0033}*) Show[ListPlot[modelData, PlotStyle -> Red], ...


10

Exponents are always a headache for fitting. Fit the Log instead: data = {{0, 100}, {.02, 81.87}, {.04, 67.03}, {0.06, 54.88}, {.08, 44.93}, {.1, 36.76}}; sol = FindFit[data /. {x_, y_} :> {x, Log@y}, la + t lb, {la, lb}, t]; {a, b} = Exp[{la, lb} /. sol]; (* {100.012, 0.0000451495} *)


4

Assume that you have assigned the variable "model" as your LinearModelFit result. Then you can get the F statistic and its p-value with: model[{"ANOVATableFStatistics", "ANOVATablePValues"}] For interactions, you can include them when you build your data. For example, assume that you have two independent variables. Build your data list as: data = ...


1

Using only the first cbMax amount of $c_b$s, we get: getmodel[a_, cbMax_] := With[{cb = Table[FindRoot[cb Cot[cb] + a L, {cb, Pi (n + 1/2), n Pi, (n + 1) Pi}][[1, 2]], {n, 0, cbMax}]}, 1 - Sum[2 cb[[i]] Sin[cb[[i]] x/L] E^(a x), {i, cbMax + 1}]] And now notice that for the rest of the $c_b$s, the difference becomes constant (Pi) very fast: ...


2

I have rewritten your code to remove function definitions from the first argument of Manipulate. It is always a bad idea to define functions in the first argument of Manipulate -- such functions get redefined every time the front end refreshes the visible contents of the Manipulate. I have also put some effort on reducing the amount of evaluation done when a ...



Top 50 recent answers are included