1
$\begingroup$

I am trying to fit this set of data,I tried a simple linear model but it didn't yield successful results, I also tried curve_fit on Python but also no luck - here they are normalized to match peaks:

enter image description here

Is there a function where I can just fit to the peak without it turning into an exponential growth function?

enter image description here

        data1 = {{947.57, 37.8841}, {947.65, 32.8244}, {947.729, 25.9307}, {947.809, 
  29.0297}, {947.889, 36.9354}, {947.968, 34.7851}, {948.048, 
  29.4724}, {948.127, 29.3459}, {948.207, 30.3579}, {948.286, 
  35.9867}, {948.365, 31.7493}, {948.445, 34.5321}, {948.524, 
  33.8364}, {948.604, 37.6311}, {948.683, 35.6072}, {948.762, 
  32.7612}, {948.842, 32.3817}, {948.921, 38.5798}, {949., 
  37.9473}, {949.079, 31.4963}, {949.158, 31.8758}, {949.238, 
  36.8722}, {949.317, 35.1645}, {949.396, 37.3781}, {949.475, 
  36.1765}, {949.554, 34.9748}, {949.633, 33.7731}, {949.712, 
  37.7576}, {949.791, 32.6347}, {949.87, 33.9629}, {949.949, 
  34.8483}, {950.028, 42.1215}, {950.107, 35.8602}, {950.185, 
  33.0774}, {950.264, 34.5953}, {950.343, 39.2122}, {950.422, 
  45.5368}, {950.501, 35.9235}, {950.579, 35.291}, {950.658, 
  36.9354}, {950.737, 48.2564}, {950.815, 43.4497}, {950.894, 
  33.5834}, {950.973, 38.0738}, {951.051, 44.9676}, {951.13, 
  44.6514}, {951.208, 34.0261}, {951.287, 41.7421}, {951.365, 
  46.8017}, {951.444, 50.3435}, {951.522, 40.2242}, {951.601, 
  39.8447}, {951.679, 39.402}, {951.757, 46.9914}, {951.836, 
  45.9795}, {951.914, 45.6}, {951.992, 40.2242}, {952.071, 
  44.6514}, {952.149, 49.711}, {952.227, 45.4103}, {952.305, 
  36.8722}, {952.383, 39.5285}, {952.462, 52.7468}, {952.54, 
  47.5607}, {952.618, 38.8328}, {952.696, 41.4891}, {952.774, 
  45.853}, {952.852, 47.3077}, {952.93, 49.1418}, {953.008, 
  45.9163}, {953.086, 42.4378}, {953.164, 48.0034}, {953.242, 
  52.1776}, {953.32, 50.5332}, {953.397, 41.3626}, {953.475, 
  48.4461}, {953.553, 46.5487}, {953.631, 50.7862}, {953.708, 
  44.9043}, {953.786, 44.5249}, {953.864, 50.217}, {953.942, 
  56.0988}, {954.019, 50.8494}, {954.097, 50.9759}, {954.174, 
  49.3948}, {954.252, 56.0356}, {954.33, 63.372}, {954.407, 
  53.316}, {954.485, 48.8256}, {954.562, 56.0988}, {954.639, 
  67.0403}, {954.717, 60.5892}, {954.794, 53.2528}, {954.872, 
  53.569}, {954.949, 62.3601}, {955.026, 66.3446}, {955.104, 
  64.7634}, {955.181, 61.3482}, {955.258, 63.625}, {955.335, 
  75.3887}, {955.413, 74.693}, {955.49, 66.3446}, {955.567, 
  64.2575}, {955.644, 72.8589}, {955.721, 76.4639}, {955.798, 
  73.9341}, {955.875, 75.5784}, {955.952, 70.7718}, {956.029, 
  79.2467}, {956.106, 82.9149}, {956.183, 74.8195}, {956.26, 
  75.8947}, {956.337, 76.2741}, {956.414, 75.8314}, {956.491, 
  84.2431}, {956.567, 82.5987}, {956.644, 84.3063}, {956.721, 
  87.4054}, {956.798, 92.971}, {956.874, 100.497}, {956.951, 
  98.7896}, {957.028, 104.292}, {957.104, 106.379}, {957.181, 
  107.391}, {957.258, 117.447}, {957.334, 121.937}, {957.411, 
  124.783}, {957.487, 131.551}, {957.564, 138.002}, {957.64, 
  146.919}, {957.717, 145.781}, {957.793, 149.07}, {957.87, 
  149.07}, {957.946, 157.861}, {958.022, 169.751}, {958.099, 
  172.597}, {958.175, 179.175}, {958.251, 175.633}, {958.327, 
  186.638}, {958.404, 210.165}, {958.48, 203.967}, {958.556, 
  201.69}, {958.632, 182.716}, {958.708, 188.345}, {958.784, 
  214.402}, {958.86, 209.533}, {958.936, 173.609}, {959.012, 
  145.149}, {959.088, 149.386}, {959.164, 168.992}, {959.24, 
  145.907}, {959.316, 98.8528}}
    
    

Ideally the fit should look like this:

enter image description here

another image for clarity:

enter image description here

$\endgroup$

2 Answers 2

2
$\begingroup$

It would be helpful if there is a model to fit taken from some considerations that come from the core of the problem. If this is not available, try this:

Manipulate[data2 = data1 /. {x_, y_} -> {x, y - 34};
 model = a + b*Exp[-c*((x - x0)^2)^z];
 ff = FindFit[data2, model, {{a, 30}, b, c, {x0, 959}}, x];
 Row[{Show[{
     ListPlot[data2, PlotRange -> All],
     Plot[model /. ff, {x, 948, 960}, PlotStyle -> Red]
     }, ImageSize -> 250],
   Show[{
     ListLogPlot[data2, PlotRange -> All],
     LogPlot[model /. ff, {x, 948, 960}, PlotStyle -> Red]
     }, ImageSize -> 250]
   }], {{z, 0.424}, 0.2, 0.9, Appearance -> "Labeled"}]

It returns this:

enter image description here

I hope I understood you right, and it is something you are looking for.

Have fun!

$\endgroup$
0
1
$\begingroup$

You could try a truncated Fourier series:

poly = LinearModelFit[data1, 
  Join[Table[Sin[i 0.1 x  i], {i, 4}], Table[Cos[0.1 x i ], {i, 4}]], 
  x]
Plot[poly[x], {x, 947.5, 960}, Epilog -> Point[data1]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.