gnuplotで作成した複数のヒストグラムに関数をフィッティングし、その結果を同時に表示させたいです。
関数は f(x) = aexp(-(x-b)**2/(2c**2)) です。
イメージはこのようなものになります。
よろしくお願い致します。
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
質問文は編集できます
無駄に質問建てないで、追記修正しよう

回答1件
0
ベストアンサー
gnuplot
1# data 2$data1 <<EOD 3-2.2 4-1.3 5-1.25 6-1.2 7-1.1 8-0.9 9-0.85 10-0.8 11-0.7 12-0.6 13-0.5 14-0.4 15-0.35 16-0.3 17-0.25 18-0.2 19-0.1 200.1 210.2 220.25 230.3 240.35 250.4 260.45 270.5 280.6 290.65 300.7 310.8 320.85 330.9 341.1 351.2 361.3 371.4 382.2 39EOD 40 41$data2 <<EOD 422.2 433.1 443.2 453.25 463.3 473.35 483.4 493.5 503.6 513.7 523.8 533.85 543.9 554.1 564.2 574.25 584.3 594.35 604.4 614.5 624.6 634.7 644.8 654.85 664.9 675.1 685.2 695.3 705.4 716.2 72EOD 73 74# setting 75set xrange [-6:8] 76set yrange [0:20] 77set xtics 1 78set boxwidth 1 79 80# save histogram data to a temporary file 81temp_data1 = 'hist_temp1.dat' 82set table temp_data1 83plot $data1 u (floor($1)+0.5):(1) smooth frequency with boxes 84unset table 85 86temp_data2 = 'hist_temp2.dat' 87set table temp_data2 88plot $data2 u (floor($1)+0.5):(1) smooth frequency with boxes 89unset table 90 91# fitting 92f(x,a,b,c) = a*exp(-(x-b)**2/(2*c**2)) 93fit f(x,a1,b1,c1) temp_data1 u 1:2 via a1,b1,c1 94fit f(x,a2,b2,c2) temp_data2 u 1:2 via a2,b2,c2 95 96# plot 97plot $data1 u (floor($1)+0.5):(1) smooth frequency with boxes, f(x,a1,b1,c1) w l, \ 98 $data2 u (floor($1)+0.5):(1) smooth frequency with boxes, f(x,a2,b2,c2) w l
投稿2022/01/31 01:10
総合スコア21118
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。