Why A Cascading SMA Approximate A Gaussian Filter ?

Introduction

The gaussian filter don't see many uses in technical analysis and financial data smoothing in general, however it possess really interesting properties and a really close relationship with the simple moving average.

The gaussian filter is a filter which possess a function approximately gaussian (bell shaped curve) as : impulse response, step response and frequency response. This characteristic is pretty cool actually, the gaussian function is always mysterious.

Now why do I talk about sma and estimation ? Well it is true, you can estimate a gaussian filter by applying an sma to another sma and so on such as : sma(...sma())

But why ? Just why is that so ? Well there are a lot of explanations, some of them involving the central limit theorem which would lead to a statistical explanation but I'll give a simpler explanation of this case by using signal processing.

Understanding Impulses Responses

The impulse response of a filter is the filter output using an impulse function as input or more simply : filter(impulse)

The impulse function is a simple function equal to 1 at a certain point in time, for example we can use : impulse = 1 if t = 10 else 0, where t = 1,2,3...inf

The impulse response of a filter tell us how to actually make the filter, for example :

a = filter(impulse)
b = sum(input*a) = filter(input)


This process is called convolution, and is simply the sum of the product of two functions, the input function and the kernel function, a kernel is just a way to say filter coefficients.

The Explanation

Now that you know that, let's explain why sma(...sma()) approximate a gaussian filter.

To do so let's take an impulse function and let's start applying an sma to it such as sma(impulse) (the sma period doesn't matter here)

snapshot

Only one sma give a constant, let's use two sma's such as sma(sma(impulse))

snapshot

This give us a triangular function, this is why sma(sma()) is often called triangular moving average, now let's repeat the process and add more sma's.

snapshot

Do you see ? We are approximating a gaussian curve, if we do it many times the approximation will be even more correct.

Now let's recall :

The impulse response of a gaussian filter is a gaussian function f

The impulse response of many sma's give a function f' who approximate a gaussian function, therefore f ≈ f'

So sum(input*f') ≈ sum(input*f) and therefore sma(...sma(input)) ≈ gaussfilter(input)

Note : the process of applying a filter several time is called cascading

Conclusion

Simple isn't it ? The simple moving average is always fun to use and posses many properties, now you don't want to use such method because it's mega inefficient.

But maybe that you want to know about an efficient gaussian filter implementation ? I can work on it. Thanks for reading !

Beyond Technical AnalysisdspfiltergaussgaussiangaussianfilterMoving Averagestriangularmovingaverage

Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/
Also on:

Disclaimer