Hot answers tagged

6

Try this: model = 1 + a*Exp[-b*x]; ff = FindFit[samplelist, model, {a, b}, x] Show[{ ListPlot[samplelist], Plot[model /. ff, {x, 0, 2}, PlotStyle -> Red] }] (* {a -> 13.9603, b -> 2.2877} *) with the following effect: Have fun!


6

Here's a slow way to do an exhaustive search. It does not work for lists that are larger than about 30 elements, but it is guaranteed to give the best bipartition and can be used to check the correctness of faster methods. Use a random list of length 20: SeedRandom[1234]; list = RandomVariate[NormalDistribution[], 20] (* {-0.508336, -0.0706019, -1.5939, 1....


6

You could use LinearProgramming for this. The idea is to create a cost matrix consisting of two sets of your data, one negative and one positive, and the desired minimization vector has half the ones in each part. A simple example to illustrate. Consider the following set of data: data = {15, 82, 75, 25} The LinearProgramming call would be: Quiet @ ...


3

You can play with the size of each marker this way {MarkerName,Size} xrange = {-1, 1}; xdata = {{1, 0., 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}, {1, 0, 1}}; ListLinePlot[Append[Transpose[#], Total[#, {2}]] &[xdata], DataRange -> MinMax[xrange], PlotMarkers -> {{"\[FivePointedStar]", 25}, {"\[FilledUpTriangle]", 20}, {"\...


3

Try this: data = {{45, 2.93495}, {50, 2.94697}, {55, 1.9801}, {60, 0.734437}, {65, -0.0128219}, {70, -0.695535}, {75, -1.35939}, \ {80, -1.47567}}; y = k1 - 2 Log[x, 10] + k2/2.303/(x^3 (Tm - x)^2) + 0.75 B/2.303/(x - T0) /. {T0 -> 259.246, B -> 2595.89, Tm -> 433.15}; fun[x_] = NonlinearModelFit[data, y, {k1, k2}, x] // Normal; ...


2

In this case, I would do as follows. Here is your plot: k[w_] := Exp[(-I)*w]/(1 + I*w); p = ParametricPlot[{Re[k[w]], Im[k[w]]}, {w, -Pi, 0}, PlotRange -> {{-0.7, 2.1}, {0, 1.1}}]; This is the position of the line you are looking for in the form of a list: Position[p, Line] // Flatten (* {1, 1, 1, 3, 1, 2, 0} *) One only needs to replace the ...


2

Rather than using weighted least squares with NonlinearModelFit to estimate the parameters for the Landau curve, you might consider an explicit maximum likelihood approach. Because the response variable is a count and the "errors" you give are simply the square root of the response, I'm assuming that for any particular predictor value, the response ...


2

There are two parts to this response: (1) Why a chisquare test is inappropriate for your data and objective, and (2) What you might consider as to the adequacy of the fit. Why a chisquare test is inappropriate for your data and objective. The PearsonChiSquareTest assumes that the data is a random sample from a specified probability distribution. Your &...


2

you must adapt the code to different forms of input. Here is code that reads the new file: (*input=StringToStream[str];*) input = OpenRead["FileName"]; line = ReadLine[input]; n = StringCases[line, NumberString][[1]] // ToExpression;; dat = Reap[ Do[ line = Read[input, "String"]; Sow[StringCases[line, NumberString] // ...


2

165 × 165 cannot be correct since indexes start at 0 and the last index is 167 so it has to be 168 x 168. rawData = Import["~/Downloads/file.dat", "Data"]; data = Take[rawData, {4, -2}] (* Ignore first 3 and last line *) (* Function to convert site spec like "{0,:,1,2,3;}" to array *) expandRow[spec_] := Module[ {specList = (...


1

You might consider just generating a table of points. The downside is that the spacing of the points might not be as optimal as what you get with harvesting the points from ParametricPlot. Using your example with 500 points: k[w_] := Exp[(-I)*w]/(1 + I*w); p = Table[{w, Re[k[w]], Im[k[w]]}, {w, -Pi, 0, Pi/500}]; p = Select[p, 0 <= #[[3]] <= 1.1 &&...


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