alexgrover

Using The AM/GM Inequality To Estimate Volatility

A volatility indicator derived from the AM/GM inequality. I don't think it will be necessary to describe the usage and interpretation of such indicator, and I don't think it is super useful, however, this is not the case of the script, which contains three ways to compute the geometric mean, with a classic, a simple, and an efficient way. The AM/GM inequality is also a really interesting concept, and I'll try to"prove" it in this post by using DSP. I also added more comments in the script in order to highlight some stuff.

The AM/GM Inequality

When we talk about the mean, we are referring to the "arithmetic" one by default, but there exist more types of means. Two other ones include the "geometric" and "harmonic" means, both are part of the Pythagorean means with the arithmetic mean.

Each one of them as several properties, but the most interesting aspect is their inequality, that is:

HM <= GM <= AM

The arithmetic mean is the one with the highest value, while the harmonic mean is the one with the lowest value. In the case each data point is equal to each other, all the means have the same value.

In our case, the inequality of interest is the inequality between the geometric and arithmetic mean, where the geometric mean is lower or equal than the arithmetic one. Many proofs/explanations exist, I'll try my version using DSP, where instead of thinking about means, we think about rolling means, which allows us to interpret them as low-pass filters. So we end up having the geometric moving average (GMA) and arithmetic moving average (SMA).

We know that GMA <= SMA, the SMA has a unity passband, this implies that the GMA has a passband lower than 1 (for non-equal input values), this explains why the GMA is smaller than the SMA. In order for a FIR filter to have a passband lower than 1, the sum of the filter coefficients must be lower than 1. In order to further proves this consider the following equation:

sqrt(a×b) = k×a + k×b

Here sqrt(a×b) is the geometric mean of a and b, the right-hand side of the equation is a weighted sum between a and b and coefficient k, we want to solve the equation with respect to k, if k×2 < 1 then we have the proof that GMA < SMA. The solution with respect to k is:

k = sqrt(a×b)/(a+b)

which always gives a number lower than 0.5, as such k×2 < 1 and thus the passband is lower than 1. If our input values are equal to each other, we end up with the following solution for k:

k = sqrt(a×a)/(a+a) = a/(2×a) = 0.5

as such the GMA has the coefficients of an SMA as long as the input values are equal to each other.

Because of this inequality, we can subtract the SMA to a GMA and take the square root of the result in order to have a volatility indicator, however, both moving averages are still pretty close to each other, which gives a very small result for the indicator.

Uwu I am a bit tired, better indicators coming up

Check out the indicators we are making at luxalgo: www.tradingview.com/u/LuxAlgo/
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?