Rolling Excess Kurtosis (KURTOSIS)
Summary
An estimate, from the trailing window, of the excess kurtosis of the distribution its values come from: the fourth standardised moment minus 3, so a normal distribution reads 0. A tail-weight measure: above 0 the distribution has heavier tails than a normal one with the same variance, below 0 lighter ones. The companion to the shipped VAR and STDDEV in the same group.
Chart
Chart metadata i
Outputs
outReal:line·zero·positive·negative
Formula
Sample-adjusted Fisher excess kurtosis, the estimator usually written G2. With window size n, window mean x̄, and sample variance s² = Σ(x−x̄)²/(n−1):
G2 = [ n(n+1) / ((n−1)(n−2)(n−3)) ] · [ Σ(x−x̄)⁴ / s⁴ ] − 3(n−1)² / ((n−2)(n−3))
The result is NaN when s² = 0, that is when every value in the window is equal.
optInTimePeriod must be at least 4: the (n−2)(n−3) denominators are undefined below it. The bound is enforced by the parameter range, so a shorter period is refused rather than silently degraded.
Notes
- This is
G2, the form ExcelKURTandscipy.stats.kurtosis(bias=False)compute. The other form in circulation is the biasedg2 = m₄/m₂² − 3over population moments, a different estimator rather than a rounding convention:G2 = (n−1)((n+1)·g2 + 6) / ((n−2)(n−3)). - A point mass has no defensible excess kurtosis, so the degenerate window is NaN rather than a number:
0would assert normality and−1.2uniformity. This is deliberately unlikeVAR, which floors to zero — a variance of zero says something true about the window. - The result is at most
n, the value of one reading apart fromn−1equal ones, so a window dominated by one outlier is legitimately far above 0.
Inputs
inReal— The series to measure
Outputs
outReal— Excess kurtosis of the trailing window, or NaN where the window has no spread
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 30 | 4–10000 | Number of trailing values in the window |
Properties
Numerical Stability: Start-Independent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ✅ Can Output NaN or ±Inf i |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double series[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_KURTOSIS( 0, n - 1, series, 30, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d; last out = %f\n", outNBElement, outBegIdx, out[outNBElement - 1] );use ta_lib::Core;
let series = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.kurtosis(0, series.len() - 1, &series, 30, &mut out)?;
println!("{} values from bar {}; last out = {}", range.count, range.beg_idx, out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
double[] series = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.kurtosis(0, series.length - 1, series, 30, out);
System.out.println(r.count() + " values from bar " + r.begIdx() + "; last out = " + out[r.count() - 1]);using System;
using TALib;
var series = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Kurtosis(0, series.Length - 1, series, 30, outReal);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}; last outReal = {outReal[r.Count - 1]}");import { kurtosis } from 'ta-lib';
const series = new Float64Array(252); // your data, oldest first
const { begIdx, values } = kurtosis(series, { timePeriod: 30 });
console.log(values.length + ' values from bar ' + begIdx + '; last values = ' + values[values.length - 1]);Implementation
Added in 0.8.3 (ta-lib-python 0.8.3).
TA-Lib Definition: kurtosis.c · kurtosis.yaml
| Native | File |
|---|---|
| C | ta_KURTOSIS.c |
| Rust | kurtosis.rs |
| Java | Core_KURTOSIS.java |
| C# | Core_KURTOSIS.cs |
| TypeScript | kurtosis.ts |
Python: talib.KURTOSIS (ta-lib-python 0.8.3 or later), see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Excess Kurtosis, Sample Excess Kurtosis, KURT
See Also
References
- Joanes, D. N. and Gill, C. A. "Comparing measures of sample skewness and kurtosis." Journal of the Royal Statistical Society: Series D, 47(1), 1998, 183-189 — the
g1/g2,G1/G2,b1/b2families and which is unbiased under which assumption. - NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.11 — the biased population form.
- Microsoft, KURT function — the
G2form, and#DIV/0!for fewer than four points or zero standard deviation.