Tag Info

New answers tagged

0

I prefer the more general function; you can do : data = Transpose[ Join[Transpose[ MasterDataInputs[[2 ;;]]], {MasterDataOutput[[2 ;;]]}]][[1 ;; 2]] ; nlm = NonlinearModelFit[data, a0 + a1 x1 + a2 x2 + a3 x3 + a4 x4 + a5 x5, {a0, a1, a2, a3, a4, a5}, {x1, x2, x3, x4, x5}] nlm // Normal (* 1254.18 +0.0102011 x1+0.00115933 x2+0.00164517 ...


4

As usual, it's a matter of choosing a better starting values for the parameters. I started writing this answer before the data file was uploaded, so here's some synthetic data: data = Table[ Interpolation[{{0, 1.1*^-6}, {200, 1.1*^-6}, {250, 9.5*^-7}, {500, 9.5*^-7}}, x, InterpolationOrder -> 1] + 2*^-8 ...


2

You can try to improve it "by hand", as follows. Assume that the model is like this: model = (a*(Exp[c*t] - 1))/(1 + b*Exp[c*t]) and assume that you have in mind that your data correspond to {{1, intensity1}, {2, intensity2},...} (see my comment above) and assume that norm is the name of your data. Try the following: Clear[model, a, b, c]; model = ...


4

ff = FindFit[normalized, {fitEquation2}, {y0, a, k}, t] Show[ListLinePlot@normalized, Plot[fitEquation2 /. ff, {t, 0, 20}, Evaluated -> True]]


13

Something strange happens when you allow your lines in your model to have a gap at point k. You also specified UnitStep functions wrongly - see my version below. You do realize your model function allows for gap? It is better to have less parameters in the model. Obviously your data assume that lines meet without gap. Why not to explicitly specify this ...


3

Following @Vitaliy's comment try this formulation: kB = QuantityMagnitude@ UnitConvert[Quantity["BoltzmannConstant"] , "Joule/Kelvin"] pdf[dp_?NumericQ, d0p_?NumericQ, w_?NumericQ] = kB^(-1/3)/(w Sqrt[2 Pi]) 1/dp *E^(-1/(2 w^2) (Log[dp /d0p])^2); mt[b_?NumericQ, Nt_?NumericQ, Ms_?NumericQ, d0p_?NumericQ, w_?NumericQ] := Nt kB^(4/3) Ms Pi /6 ...


4

As b.gatessucks comments you can use inset. You can also use PlotLegends and customize, e.g. tab = nlm["ParameterTable"] plt = Show[ Plot[nlm[t], {t, 0, 5}, PlotRange -> Full, PlotLegends -> Placed[LineLegend[{Blue}, {Normal@nlm[t]}, LegendMarkerSize -> {50, 3}, LegendFunction -> (Column[{#, tab}, Frame -> True] ...


2

Your model seems to be problematic. With a standard step-shaped model: ´model = a/(1 + b*Exp[-c (x - d)])´ you immediately find a simple enough solution. Assuming that ´lst´ is your list try this: model = a/(1 + b*Exp[-c (x - d)]); ff = FindFit[lst, model, {a, b, c, d}, x] (* {a -> 1.00153, b -> 0.437, c -> 13.2399, d -> 0.454211} *) This ...


0

You can try a chi-square fitting. Something like this: model[x_, a_, b_, c_] := a x^2 + b x + c chi2[a_, b_, c_] :=Total@Table[((data[[i, 2]] - model[data[[i, 1]], a, b, c])/error[[i]])^2, {i, 1, Length[data]}] res = NMinimize[chi2[a, b, c], {a, b, c}] this gives output: (*{38.0714, {a -> 0.908647, b -> -0.75179, c -> -1.0329}}*) Of course ...


4

Here is a solution -- I added a constraint and manually found some good initial values. g[z_] = Simplify[ 5 Log[10,(1 + z ) Integrate[1/(a + b x + c x^2), {x, 0, z}] ] + 25 , Assumptions -> {z > 0, -b^2 + 4 a c > 0 }] 5 (5 + Log[10,-((2 (1 + z) (ArcTan[b/Sqrt[-b^2 + 4 a c]] - ArcTan[(b + 2 c ...


5

There is actually a fair bit going on here that can make this confusing. The critical thing is the difference between testing fit to a family of distributions compared to testing fit to a particular distribution. Let me demonstrate. SeedRandom[23]; data = RandomVariate[NormalDistribution[1, 2], 100]; DistributionFitTest[data, NormalDistribution[mu, ...


1

My reading of the error message you are getting is that if you try λp[85.] = 6540 λp[100.] = 6540 Psat[85.] = 78896.6 Psat[100.] = 323767 your original formulation might work. λp[100] is not the same as λp[100.]. Similarly for λp[85] and Psat, too.


4

If you wanted to automate things you might do something like this: tests = Sort[(g = DistributionFitTest[ w, #, {"PValue", "FittedDistribution"}]) & /@ { GammaDistribution[a, b, c, d], NormalDistribution[a, b], ChiSquareDistribution[a], HalfNormalDistribution[a], ...


12

The mathematica help is very thorough and is very indicative of what you should do next. By way of the histogram diagram obtained, you can compare your data against the proposed distribution. Show[Histogram[w[[2, 1]], Automatic, "ProbabilityDensity"], Plot[PDF[h["FittedDistribution"], x], {x, 0, 1500}, PlotStyle -> Thick]] The reference points you ...


3

First add a constant term to pos and neg as b.gatessucks suggests. Then you can bump the starting point of the parameter x1 off of the data grid, so that x - x1 is unlikely to ever be zero: data = {{0, 0}, {0.1, 0.1}, {0.2, 0.2}, {0.3, 0.3}, {0.4, 0.4}, {0.5, 0.5}, {0.6, 0.6}, {0.7, 0.7}, {0.8, 0.8}, {0.9, 0.9}, {1, 1}, {1.1, 0.9}, {1.2, 0.8}, ...


1

You could do the NonlinearModelFit yourself? Following the example in the documentation: Starting with the data data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}, {6, 4}, {7, 5}}; Extracting the ys, and xs ys = Last /@ data;xs = First /@ data; Defining some ad hoc weights wghts = Table[Exp[-(i - j)^2/8.], {i, Length[ys]}, {j, Length[ys]}] Let us define the ...


2

There are two reasons why it doesn't work. You have negative x values. Raising these to fractional d powers gives complex results. For this reason it is not sensible to use the form a x^d for fitting this data. However, you could use a Abs[x]^d instead. With this change it still won't work. The other reason is that FindFit work by minimizing (using ...



Top 50 recent answers are included