I have datapoints f(x_i) at points x_i (function f not known, only numerically) with f(0) = 0. The data show a peaklike structure at small x, to be followed by a slow shoulder-falloff at larger x that sets in half-way down from the maximum. I want to plot smoothed lines through these data points. If I use bezier then indeed f(0)=0 is ok, but the peak is significantly (by about 25%), lowered. If I use acsplines then the peak looks somewhat better, but f(0) = 0 is not maintained. How can I smooth that dataset without loosing vital info (f(0)=0) or the peak-height of the distribution?
Smoothing with acsplines draws an approximating cubic spline, which doesn't go through your original data points.
A better approach could be to use cubic splines smooth csplines, which go through all data points but may show overshoots for sharp peaks.
The probably best solution in your case is to use monotonic cubic splines, smooth mcsplines, which maintain the monotonicity and convexity of the original data points (see F.N. Fritsch and R.E. Carlson, "Monotone Piecewise Cubic Interpolation", SIAM Journal on Numerical Analysis 17, pp. 238-246 (1980)).
Here is a short example which shows these differences:
The test.dat file contains the points
0 0
0.2 1
0.4 10
0.6 80
1 30
2 20
3 13
4 7
5 2
6 1
7 0
And the script to plot them is
set xzeroaxis
set style data lines
set samples 500
plot 'test.dat' u 1:2 smooth acsplines title 'acsplines', \
'' u 1:2 smooth csplines title 'csplines', \
'' u 1:2 smooth mcsplines lw 2 title 'mcsplines',\
'' u 1:2 w p pt 7 title 'data points'

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With