# Pulse detection against various noise floors

I'm decoding a pulse amplitude modulation encoded digital signal. The goal is to detect the individual pulse against a background noise floor. The amplitude of the pulses varies depending on the signal strength and quality.

My sampling rate is 2x the bit width such that one bit fits into sample. Thus a single bit is the large value amongst the noise floor (8-bit unsigned values):

6, 1, 18, 100, 9, 4, 7


Detecting the bit is simply looking for the large value relative to its neighbors (100 in the above example). This would be easy if the noise and pulses had known constant thresholds, but in real life they vary. What I actually see is varying noise and pulse amplitude depending on the quality of the signal. Consider these samples (47 and 52 are the bits I'm trying to detect):

2, 8, 12, 47, 19, 13, 10
23, 11, 30, 52, 17, 9, 11


I've been struggling with developing an algorithm that can dynamically determine the threshold and thus pick-out the bits. I'm approaching this with a general computer science background with little to no DSP knowledge.

What are some software techniques to reliability detect a pulse against varying background noise?

Be aware that any time you mention 'threshold', you are implicitly making a statement that you are comfortable with those three probabilities:

• Certain probability of false alarms, (PFA).
• Certain probability of detection, (PD).
• Certain probability of misses, (PM).

Put another way, every time you set a threshold, those three numbers will change accordingly. This is inescapable, in any detection problem. Typically one can set the probability of false-alarm that they are willing to 'live with', and go from there.

For your problem, you mention changing noise variance. One way to circumvent this is to Z-Standardize your data vector before attempting anything. This then centers your data, (de-meaning), and forces the variance to unity. This take care of the problem of you having to re-compute thresholds all the time.

With this pre-processing step out of the way, you can now focus on your Test-Statistic, and your Threshold. For example, a test-statistic can simply be each sample. Or, it can be the average of three samples. Or the average of 10 samples. Either way, you will be comparing your test-statistic, against your threshold. Again, you pick a threshold you "can live with", that is to say, one that gives you false-alarms at a rate that your application deems acceptable.

For example, if a doctor has a false alarm rate of 10% in informing you that you have a cold, that might be acceptable for this application, because it is not the end of the world, and the worst thing that can happen is you drink more orange juice than usual. If on the other hand you are designing a fraud detection system for your bank and you false alarm in detecting fraud 10% of the time, you are going to have some very, very angry customers swearing at your representatives all day for locking their credit cards.

Back to your application: It seems that those bits are the result of a demodulated PAM receiver system, so you probably already have a significant amount of averaging gain. This means that a test-statistic of one sample is good enough to go off of. All you need to do now, is set your threshold (of your standardized data), such that you false alarm as some rate you are comfortable with.

(Remember, that you are dealing with standardized data, so you need only set this threshold once, and then forget about it. As a practical note to assist you in determining the threshold, try to plot the histogram of your data without signal, after you have standardized it. This will be your 'noise PDF'. This can assist you in estimating the optimal threshold ala Neyman_Pearson detector.)