Skewness measures the asymmetry of the probability distribution of a real-valued random variable about its mean. It tells you where the "tail" of the distribution is.
## Historical Context
Introduced by Karl Pearson in 1895, Skewness (along with Kurtosis) provides the "shape" of the distribution beyond the mean (location) and variance (spread). In finance, it's critical because returns are rarely normally distributed; they often exhibit "negative skew" (frequent small gains, occasional catastrophic losses).
## Architecture & Physics
The `Skew` indicator uses a sliding window (RingBuffer) to maintain the last $N$ samples. To ensure O(1) performance, it maintains running sums of the first three powers of the input:
* $\sum x$
* $\sum x^2$
* $\sum x^3$
This allows calculating the 2nd and 3rd central moments instantly without re-iterating the buffer.
### Stability
Calculating higher moments (like $x^3$) can lead to precision issues with large numbers. The implementation uses `double` precision and a periodic `Resync()` (every 1000 ticks) to correct any floating-point drift.
## Mathematical Foundation
We use the **Fisher-Pearson Coefficient of Skewness** (Sample Skewness), which is the standard in statistical software (like Excel's `SKEW`, Python's `scipy.stats.skew(bias=False)`).
### 1. Moments
First, we calculate the raw moments from the running sums: