KURTOSISTEST
Overview
The KURTOSISTEST
function tests whether the kurtosis of a sample is different from that of a normal distribution. This is useful in statistics for assessing the “tailedness” of the probability distribution of a real-valued random variable. The test returns a z-score and a p-value, indicating whether the sample kurtosis significantly deviates from normality. For more details, see the scipy.stats.kurtosistest documentation .
This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=KURTOSISTEST(data)
data
(2D list, required): Table or column vector of sample data (must contain at least 20 elements).
The function returns a 2D list: the first element is the z-score (float), and the second is the p-value (float), or an error message (string) if the input is invalid.
Examples
Example 1: Normal Data
Inputs:
data |
---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
Excel formula:
=KURTOSISTEST({1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20})
Expected output:
z-score | p-value |
---|---|
-1.7058 | 0.0880 |
Example 2: High Kurtosis Data
Inputs:
data |
---|
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
100 |
Excel formula:
=KURTOSISTEST({1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;100})
Expected output:
z-score | p-value |
---|---|
4.6940 | 0.0000 |
Example 3: Low Kurtosis Data
Inputs:
data |
---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
100 |
Excel formula:
=KURTOSISTEST({1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;100})
Expected output:
z-score | p-value |
---|---|
4.4793 | 0.0000 |
Example 4: All Same Value
Inputs:
data |
---|
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
5 |
Excel formula:
=KURTOSISTEST({5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5;5})
Expected output:
z-score | p-value |
---|---|
nan | nan |
Python Code
from scipy.stats import kurtosistest as scipy_kurtosistest
def kurtosistest(data):
"""
Test whether the kurtosis of a sample is different from that of a normal distribution.
Args:
data: 2D list. Sample data (must contain at least 20 elements).
Returns:
2D list: [[z-score, p-value]], or an error message (str) if input is invalid.
This example function is provided as-is without any representation of accuracy.
"""
# Validate input
if not isinstance(data, list) or len(data) < 20:
return "Invalid input: data must be a 2D list with at least 20 elements."
# Flatten 2D list to 1D
try:
flat = [float(row[0]) if isinstance(row, list) else float(row) for row in data]
except Exception:
return "Invalid input: data must contain numeric values."
if len(flat) < 20:
return "Invalid input: data must contain at least 20 numeric values."
try:
z, p = scipy_kurtosistest(flat)
except Exception as e:
return f"scipy.stats.kurtosistest error: {e}"
# Check for nan/inf
if any([x is None or isinstance(x, str) for x in [z, p]]):
return "Invalid result: z-score or p-value is not a number."
import math
if any([math.isnan(z), math.isnan(p), math.isinf(z), math.isinf(p)]):
return [["nan", "nan"]]
return [[z, p]]