In the R TTR package the Garman-Klass volatility is given by

```
# Historical Open-High-Low-Close Volatility: Garman Klass
# https://web.archive.org/web/20100326172550/http://www.sitmo.com/eq/402
if( calc=="garman.klass" ) {
s <- sqrt( N/n * runSum( .5 * log(OHLC[,2]/OHLC[,3])^2 -
(2*log(2)-1) * log(OHLC[,4]/OHLC[,1])^2 , n ) )
}
```

which corresponds to*

$$ \sigma = \sqrt{ \frac{Z}{n} \sum \left[ \textstyle\frac{1}{2}\displaystyle \left( \log \frac{H*i}{L*i} \right)^2 - (2\log 2-1) \left( \log \frac{C*i}{O*i} \right)^2 \right] }. $$

I think this code is fairly self-explanatory but what's what?

`Z =`

Number of closing prices in a year, `n =`

number of historical prices used for the volatility estimate.

- $\LaTeX$ taken from the vignette.