Should zero element be considered to calculate mean when smoothing spectrogram by window?

My (mass spectrometry) spectrogram does not measure the intensity constantly. I obtain the spectrogram, for example,

time(seconds) = [0,1,2,3,4,5,6,7,8,9]
intensity_profile = [0,10,0,0,50,75,0,60,20]


The 0 in intensity is when the machine does not do measurement (but in fact, it has some signal). If the window is 3 seconds and I choose to use mean, should I average only non-zero element?

smooth_intensity_profile = [10,62.5,40]


Or I should count zero as elements for denominator, and the result would be

smooth_intensity_profile = [3.33,41.67,26.67]


You don't seem to exactly perform smoothing, but instead averaging by non-overlapping blocks of 3 and downsampling. A sound answer cannot be given without the knowledge of what you want to do from this data simplification.

However, using the zeros possesses the highest risk for me, as this biases the result with values that actually are unknown. Using the non-zero values only is in fact assuming the following model (0-order): the expected value for unknown ones is the average of the known values: if you replace zeros by such a mean, you don't change the result.

Using higher-order models or additional assumptions, you might be able to get more interesting smoothing.

• If I have overlapping block, such as the window is 3 seconds and shift is 2 seconds (1 second overlap between windows), is it considered to be smoothing? What I want to do here is reducing the dimension of very large mass spectrogram matrix along time axis for faster factorization. May you please tell me more about what are higher-order models in this case? Also, is it safer if I use summation instead of mean?
– Jan
Oct 24, 2017 at 4:11
• Yes, this remains consistent with smoothing. Even with a 1-second shift. And anything larger that a 1-second shift involves some kind of sub-sampling. I understand the need of faster processing, but crude smoothing and sub-sampling could degrade results. If you can tell (and show) what your matrices here, how you want to factorize them, you could have better answers. Finally, why do you call them spectrogram? (I know a bit about mass spectra, but spectrograms have special meaning in DSP) Oct 25, 2017 at 17:29
• The profile from mass spectrometry can be plotted in 3D from the information of mass-per-charge, time, and intensity. I am sorry if I am wrong but I think this is spectrogram? I add the visualization of matrix in the question. Each bright dot represents the peak of intensity for that detected mass-per-charge at that time. What do you think about smoothing here?
– Jan
Nov 1, 2017 at 10:58
• I would call it a spectrograph. Maybe a spectrogram is more appropriate in analysis. However, this refers to a sliding Fourier analysis in DSP. Your matrix looks quite sparse. I 'm very doubtful of constant mean smoothing Nov 1, 2017 at 17:06
• Yes, it is very sparse. May you have some recommended method names for me to read more?
– Jan
Nov 3, 2017 at 11:58