2

ここに画像の説明を入力適合がデータにとってあまり良くないことがわかるので、このプロットに適合させようとします。

私のコードは次のとおりです。

    clear
reset


set terminal pngcairo size 1000,600 enhanced font 'Verdana,10'
set output 'LocalEnergyStepZoom.png'
set ylabel '{/Symbol D}H/H_0'
set xlabel 'n_{step}'
set format y '%.2e'

set xrange [*:*]
set yrange [1e-16:*]

f(x) = a*x**b
fit f(x) "revErrEnergyGfortCaotic.txt" via a,b


set logscale

plot 'revErrEnergyGfortCaotic.txt' w p,\
 'revErrEnergyGfortRegular.txt' w p,\
f(x) w l lc rgb "black" lw 3 

exit

問題は、ここでどのように計算するかです。対数平面では、コードに入力した形式の適合は、データを非常にうまく表現する必要があると思うからです。

どうもありがとう

最後に、Christop の回答の提案を使用して問題を解決し、少し変更することができます。

関数のおおよその傾き (-4 に近い値) を見つけた後、このパラメーターを修正して、a だけで曲線をフィットさせ、それを修正して b だけを変更しました。その後、出力をフィットの開始ソリューションとして使用して、最適なフィットを見つけました。 ここに画像の説明を入力

4

4 に答える 4

1

ここでの主な問題は、より高い x 値の関数値の残差が、より低い x 値での残差と比較して非常に小さいことです。結局、あなたは y 軸でほぼ 20 桁にまたがっています。

y 値を で重み付けする1/y**2か、さらに良い: データ ポイントの標準偏差がある場合は、値を で重み付けします1/std**2。そうすれば、フィットははるかによく収束するはずです。

gnuplot では、 3 番目のデータ列を使用して重み付けが行われます。

fit f(x) 'data' using 1:2:(1/$2**2") via ... 

または、Raman Shah のアドバイスを使用して、y 軸を線形化し、線形回帰を実行できます。

于 2014-11-11T13:22:24.630 に答える
1

この種のフィッティングには 1 つのグローバル ソリューションがないため、適切なフィッティングを取得するには、適切な開始値を見つける必要があります。と を定義しないab、両方がどちらに設定さ1れるかが遠すぎる可能性があります。使ってみて

a = 100
b = -3

より良いスタートのために。これらの値をもう少し微調整する必要があるかもしれませんが、データ ファイルがないためできませんでした。

また、フィッティングの領域を 10 を超える部分に制限することもできます。

fit [10:] f(x) "revErrEnergyGfortCaotic.txt" via a,b

もちろん、それが適切な場合に限ります。

于 2014-05-13T18:29:26.223 に答える
1

This is a common issue in data analysis, and I'm not certain if there's a nice Gnuplot way to solve it.

The issue is that the penalty functions in standard fitting routines are typically the sum of squares of errors, and try as you might, if your data have a lot of dynamic range, the errors for the smallest y-values come out to essentially zero from the point of view of the algorithm.

I recently taught a course to students where they needed to fit such data. Lots of them beat their (matlab) fitting routines into submission by choosing very stringent convergence criteria, but even this did not help too much.

What you really need to do, if you want to fit this power-law tail well, is to convert the data into log-log form and run a linear regression on that log-log representation.

于 2014-05-13T18:31:30.610 に答える