KURTOSIS
Overview
The KURTOSIS
function computes the kurtosis (Fisher or Pearson) of a dataset. Kurtosis is a measure of the “tailedness” of the probability distribution of a real-valued random variable. This function flattens the input, ignores non-numeric values, and always omits NaN values (nan_policy is set to ‘omit’). Excel’s KURT function computes excess kurtosis (Fisher); this function allows both Fisher and Pearson forms. For more details, see the scipy.stats.kurtosis documentation .
This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=KURTOSIS(data, [fisher], [bias])
data
(2D list, required): Data to compute kurtosis for. Must have at least two numeric elements after flattening.fisher
(bool, optional, default=True): If True, Fisher’s definition is used (normal ==> 0.0). If False, Pearson’s definition is used (normal ==> 3.0).bias
(bool, optional, default=True): If False, then the calculations are corrected for statistical bias.
The function returns a single value (float): the kurtosis of the data, or an error message (string) if the input is invalid. NaN values are always omitted.
Examples
Example 1: Fisher, bias=True
Inputs:
data | fisher | bias | |||
---|---|---|---|---|---|
1 | 2 | 3 | 4 | TRUE | TRUE |
Excel formula:
=KURTOSIS({1;2;3;4}, TRUE, TRUE)
Expected output:
Result |
---|
-1.36 |
Example 2: Pearson, bias=True Inputs:
data | fisher | bias | |||
---|---|---|---|---|---|
1 | 2 | 3 | 4 | FALSE | TRUE |
Excel formula:
=KURTOSIS({1;2;3;4}, FALSE, TRUE)
Expected output:
Result |
---|
1.64 |
Example 3: Fisher, bias=False Inputs:
data | fisher | bias | |||
---|---|---|---|---|---|
1 | 2 | 3 | 4 | TRUE | FALSE |
Excel formula:
=KURTOSIS({1;2;3;4}, TRUE, FALSE)
Expected output:
Result |
---|
-1.2 |
Example 4: Pearson, bias=False Inputs:
data | fisher | bias | |||
---|---|---|---|---|---|
1 | 2 | 3 | 4 | FALSE | FALSE |
Excel formula:
=KURTOSIS({1;2;3;4}, FALSE, FALSE)
Expected output:
Result |
---|
1.8 |
Python Code
from scipy.stats import kurtosis as scipy_kurtosis
def kurtosis(data, fisher=True, bias=True):
"""
Computes the kurtosis (Fisher or Pearson) of a dataset.
Flattens the input, ignores non-numeric values, and always omits NaN values (nan_policy is set to 'omit').
This example function is provided as-is without any representation of accuracy.
"""
# Flatten and filter numeric values
try:
flat = [float(x) for row in data for x in (row if isinstance(row, list) else [row]) if isinstance(x, (int, float, type(None))) and x is not None]
except Exception:
return "Two or more data elements are needed"
if len(flat) < 2:
return "Two or more data elements are needed"
try:
result = scipy_kurtosis(flat, fisher=fisher, bias=bias, nan_policy='omit')
return round(float(result), 2)
except Exception:
return "Error computing kurtosis"