5
$\begingroup$

I want to reshape/smooth the following data:

gamma={
{0., 0.235269}, {0.02, 0.229659}, {0.04, 0.224064}, {0.06,0.218485}, {0.08, 0.212923}, {0.1, 0.207379}, {0.12,0.201855}, {0.14,0.196353}, {0.16, 0.190874}, {0.18,0.185421}, {0.2, 0.179995}, {0.22,0.1746}, {0.24, 0.169238}, {0.26,0.163913}, {0.28, 0.158627}, {0.3,0.153384}, {0.32,0.14819}, {0.34, 0.143048}, {0.36, 0.137965}, {0.38,0.132947}, {0.4, 0.127999}, {0.42, 0.123131}, {0.44,0.118352}, {0.46,0.11367}, {0.48, 0.109098}, {0.5,0.104649}, {0.52, 0.100336}, {0.54, 0.0961758}, {0.56,0.0921875}, {0.58, 0.0883914}, {0.6, 0.0848107},{0.62,0.0814711}, {0.64, 0.0784008}, {0.66, 0.0756304}, {0.68,0.0731923}, {0.7, 0.0711201}, {0.72, 0.0694465}, {0.74,0.0682012}, {0.76, 0.0674068}, {0.78, 0.067074}, {0.8,0.0671932}, {0.82, 0.0677263}, {0.84, 0.0685938},{0.86,0.0696635}, {0.88, 0.0707382}, {0.9, 0.0715837}, {0.92,0.0723992}, {0.94, 0.0732458}, {0.96, 0.0740598}, {0.98,0.0747586}, {1., 0.0752395}, {1.02, 0.0753813}, {1.04,0.0752247}, {1.06, 0.0748585}, {1.08, 0.0743271}, {1.1,0.0736906}, {1.12, 0.073026}, {1.14, 0.0724292}, {1.16,0.0721029}, {1.18, 0.0721423}, {1.2, 0.0724895}, {1.22,0.0730663}, {1.24, 0.0737686}, {1.26, 0.0744597}, {1.28,0.0748476}, {1.3, 0.0746472}, {1.32, 0.0738905}, {1.34,0.0726507}, {1.36, 0.0710396}, {1.38, 0.0692057}, {1.4,0.0675227}, {1.42, 0.0666539}, {1.44, 0.0665287}, {1.46,0.0670245}, {1.48, 0.0680135}, {1.5, 0.0693562}, {1.52,0.0708603}, {1.54, 0.0720217}, {1.56, 0.0727481}, {1.58,0.0730951}, {1.6, 0.0731381}, {1.62, 0.0729729}, {1.64,0.0727181}, {1.66, 0.0725961}, {1.68, 0.0726691}, {1.7,0.07291}, {1.72, 0.0732853}, {1.74, 0.0737549}, {1.76,0.0742721}, {1.78, 0.0748587}, {1.8, 0.0756793}, {1.82,0.0769077}, {1.84, 0.0787294}, {1.86, 0.0813377}, {1.88,0.0849278}, {1.9, 0.0896083}, {1.92, 0.0951742}, {1.94,0.101348}, {1.96, 0.107816}, {1.98, 0.114231}, {2., 0.12021}, {2.02,0.125595}, {2.04, 0.131118}, {2.06, 0.137176}, {2.08,0.144141}, {2.1, 0.15242}, {2.12, 0.162474}, {2.14,0.174727}, {2.16, 0.188301}, {2.18, 0.202597}, {2.2,0.21724}, {2.22, 0.231765}, {2.24, 0.245597}, {2.26,0.25801}, {2.28, 0.268195}, {2.3,0.276589}, {2.32, 0.28373}, {2.34,0.289746}, {2.36, 0.294389}, {2.38, 0.297231}, {2.4,0.304172}, {2.42, 0.320876}, {2.44, 0.347966}, {2.46,  0.387543}, {2.48, 0.444091}, {2.5, 0.52661}, {2.52,0.641105}, {2.54,0.779722}, {2.56, 0.947065}, {2.58,1.14903}, {2.6, 1.39341}, {2.62, 1.69239}, {2.64, 2.0517}, {2.66,2.4213}, {2.68, 2.76526}, {2.7, 3.06049}, {2.72,3.28789}, {2.74,3.40201}, {2.76, 3.34047}, {2.78, 3.29255}, {2.8, 3.35736}, {2.82,3.57565}, {2.84, 4.02724}, {2.86, 4.9107}, {2.88, 6.8093}, {2.9,10.3673}, {2.92, 16.4}, {2.94, 25.5976}, {2.96, 38.4815}, {2.98,62.8303}  
}

which, when plotted, look like:

no description here

I want to get rid of the bumps, oscillations, e.g. at $\sim 2.5-2.8~eV$. I used

ExponentialMovingAverage[MovingMap[Mean, gamma, {0.16,Right,Automatic},None], 0.065]

which was somewhat okay, but doesn't work satisfying anymore after the Kernel was quit. Afterwards I want to use FindFormula:

FindFormula[gamma, x, 3,PerformanceGoal -> "Quality", SpecificityGoal -> Infinity]

which gave me previously

  0.07415952155402779` + 2.253522774452971` Log[x]^15  

Combined in one plot, where the blue line is the found formula:

enter image description here

Since I'm only interested in energies below $2.6~eV$ this was acceptable but I know this can be a achieved way better. But as a newbie in Mathematica my capabilities are very limited

$\endgroup$

2 Answers 2

6
$\begingroup$

I would always check simple log / log-log spaces for your data. They look very nicely more like cubic in log-space:

ListLogPlot[gamma, PlotRange -> All, PlotTheme -> "Detailed"]

enter image description here

So transform to that log space and try fitting that:

gammaLog = Transpose[MapAt[Log, Transpose[gamma], 2]];
fitLog = FindFormula[gammaLog, PerformanceGoal -> "Quality"];
fitLog[x]
(*-1.3239779106223315`-1.8181372529411417` x+0.36137302563406115` x^3*)

The guess and fit are pretty good:

Plot[fitLog[x], {x, 0, 3}, Epilog -> {Red, Point[gammaLog]}, 
PlotTheme -> "Detailed"]

enter image description here

So going back into original space looks good too:

Plot[Exp[fitLog[x]], {x, 0, 3}, Epilog -> {Red, Point[gamma]}, 
 PlotTheme -> "Detailed", PlotRange -> All]

enter image description here

If you need values under some threshold just cut off unneeded stuff from dataset so your fit is not affected by those points.

$\endgroup$
3
$\begingroup$

You might get the kind of fit you want by simply dropping all the data points with greater than 2.6 eV.

gamma = 
  {{0., 0.235269}, {0.02, 0.229659}, {0.04, 0.224064}, {0.06, 0.218485}, 
   {0.08, 0.212923}, {0.1, 0.207379}, {0.12, 0.201855}, {0.14, 0.196353}, 
   {0.16, 0.190874}, {0.18, 0.185421}, {0.2, 0.179995}, {0.22, 0.1746}, 
   {0.24, 0.169238}, {0.26, 0.163913}, {0.28, 0.158627}, {0.3, 0.153384}, 
   {0.32, 0.14819}, {0.34, 0.143048}, {0.36, 0.137965}, {0.38, 0.132947}, 
   {0.4, 0.127999}, {0.42, 0.123131}, {0.44, 0.118352}, {0.46, 0.11367}, 
   {0.48, 0.109098}, {0.5, 0.104649}, {0.52, 0.100336}, {0.54, 0.0961758}, 
   {0.56, 0.0921875}, {0.58, 0.0883914}, {0.6, 0.0848107}, {0.62, 0.0814711}, 
   {0.64, 0.0784008}, {0.66, 0.0756304}, {0.68, 0.0731923}, {0.7, 0.0711201}, 
   {0.72, 0.0694465}, {0.74, 0.0682012}, {0.76, 0.0674068}, {0.78, 0.067074}, 
   {0.8, 0.0671932}, {0.82, 0.0677263}, {0.84, 0.0685938}, {0.86, 0.0696635}, 
   {0.88, 0.0707382}, {0.9, 0.0715837}, {0.92, 0.0723992}, {0.94, 0.0732458}, 
   {0.96, 0.0740598}, {0.98, 0.0747586}, {1., 0.0752395}, {1.02, 0.0753813}, 
   {1.04, 0.0752247}, {1.06, 0.0748585}, {1.08, 0.0743271}, {1.1, 0.0736906}, 
   {1.12, 0.073026}, {1.14, 0.0724292}, {1.16, 0.0721029}, {1.18, 0.0721423}, 
   {1.2, 0.0724895}, {1.22, 0.0730663}, {1.24, 0.0737686}, {1.26, 0.0744597}, 
   {1.28, 0.0748476}, {1.3, 0.0746472}, {1.32, 0.0738905}, {1.34, 0.0726507}, 
   {1.36, 0.0710396}, {1.38, 0.0692057}, {1.4, 0.0675227}, {1.42, 0.0666539}, 
   {1.44, 0.0665287}, {1.46, 0.0670245}, {1.48, 0.0680135}, {1.5, 0.0693562}, 
   {1.52, 0.0708603}, {1.54, 0.0720217}, {1.56, 0.0727481}, {1.58, 0.0730951}, 
   {1.6, 0.0731381}, {1.62, 0.0729729}, {1.64, 0.0727181}, {1.66, 0.0725961}, 
   {1.68, 0.0726691}, {1.7, 0.07291}, {1.72, 0.0732853}, {1.74, 0.0737549}, 
   {1.76, 0.0742721}, {1.78, 0.0748587}, {1.8, 0.0756793}, {1.82, 0.0769077}, 
   {1.84, 0.0787294}, {1.86, 0.0813377}, {1.88, 0.0849278}, {1.9, 0.0896083}, 
   {1.92, 0.0951742}, {1.94, 0.101348}, {1.96, 0.107816}, {1.98, 0.114231}, 
   {2., 0.12021}, {2.02, 0.125595}, {2.04, 0.131118}, {2.06, 0.137176}, 
   {2.08, 0.144141}, {2.1, 0.15242}, {2.12, 0.162474}, {2.14, 0.174727}, 
   {2.16, 0.188301}, {2.18, 0.202597}, {2.2, 0.21724}, {2.22, 0.231765}, 
   {2.24, 0.245597}, {2.26, 0.25801}, {2.28, 0.268195}, {2.3, 0.276589}, 
   {2.32, 0.28373}, {2.34, 0.289746}, {2.36, 0.294389}, {2.38, 0.297231}, 
   {2.4, 0.304172}, {2.42, 0.320876}, {2.44, 0.347966}, {2.46, 0.387543}, 
   {2.48, 0.444091}, {2.5, 0.52661}, {2.52, 0.641105}, {2.54, 0.779722}, 
   {2.56, 0.947065}, {2.58, 1.14903}, {2.6, 1.39341}};

formulas = 
  FindFormula[gamma, x, 5, 
    PerformanceGoal -> "Quality", 
    SpecificityGoal -> .9, 
    TargetFunctions -> {Plus, Times, Exp, Power}]
{0.106594 + 4.55534 x (4.64585 + x)^(4.42054 (-2.86045 + x)), 
 0.106625 + 4.56433 x (4.67849 + x)^(4.41374 (-2.86045 + x)), 
 0.106854 + 1.85994 x (4.67849 + x)^(4.41374 (-2.75768 + x)), 
 0.105148 + 1.72022 x (3.56921 + x)^(4.6042 (-2.75768 + x)), 
 0.109194 + 4.54899 x (4.67849 + x)^(4.41374 (-2.86045 + x))}

These are all very similar, so let's try the first one.

f[x_] = formulas[[1]];
p1 = ListLinePlot[gamma, PlotRange -> All, PlotStyle -> Blue];
p2 = Plot[f[x], {x, 0, 2.6}, PlotRange -> {0, All}, PlotStyle -> Red];
Show[p1, p2]

plot

$\endgroup$

Your Answer

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

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