Normalise data which has peaks Some methods

#1

YData = YData / max(abs(YData));


#2

maxYdataAbs = abs(max(YData));
minYdataAbs = abs(min(YData));
YData = YData / (0.5*(maxYdataAbs + minYdataAbs));


I am not happy with neither one.

Assume that you have the following data.



Only one or two sharp peaks.
I am not happy with #1 or #2.

I am not sure anymore if the best way is to normalise to the range $[-1,1]$.

How should you normalise such a data?
You could normalize the average amplitude, i.e.

YData = YData / mean(abs(YData));


Or you could normalize the signal power to one, i.e.

YData = YData / sqrt(mean(abs(YData).^2));


If just the peaks are bothering you, you could use dynamic range compression, but that would introduce nonlinear distortions. As Phonon hinted, please tell us why you are not happy with the results and why you want to normalize your data in the first place. That would allow for a more precise answer.