Hi Pepe,
I understand you want to plot probability distribution functions for ‘detection’ and ‘in_process’.
The steep curves at the end points of the second curve are a result of 'BoundaryCorrection' property of ‘ksdesnsity’, which uses ‘log’ as default. When‘ksdensity’transforms the support, it introduces the1/xterm in the kernel density estimator. Therefore, the estimate has a peak nearx=0.
However, you can get a smooth curve by setting ‘BoundaryCorrection’ value to ‘reflection’.
[f,x]=ksdensity(in_process,pts,'support',[0 212],'BoundaryCorrection','reflection');
For further understanding please refer to ‘Estimate Density with Boundary Correction’ section of ‘ksdensity’ documentation.