Skip to content

What shape is it?

Skewness, kurtosis and modality, and how to see them before you summarize them with a number.

Introductory ~10 min8 steps

What runs in CodeSplash

You will be able to

  • Read skew and tails from a chart and from a number
  • Recognize a bimodal column and what it implies
  • Use Which distribution is this? in Insights

Read first

01

Three questions about shape

Read

Before any number, look at a histogram and ask:

  1. Is it symmetric, or does one tail run longer?
  2. Are its tails thin or heavy?
  3. How many peaks does it have?
HistogramHow is one numeric variable distributed?
View data
score
52.300
57.400
67.200
66.900
49.600
37.100
66.400
70
55.200
69.600
81.900
55.600
75.700
87.300
57.500
73.900
61.700
44.100
50.400
48.800
47.100
66.800
50
52.900
51
76.200
62.400
53.300
54.600
54.100
74.600
75.400
75
68.600
77.300
50.400
50.400
79.700
76.500
62.600
60.600
63.500
55.300
61.900
45.800
58.200
57.900
57
60.100
68.900
47.700
41.800
59.200
80.700
72.800
54.200
79.300
46.900
67.600
80.900

First 60 of 1500 rows.

02

Skew

Predict

Predict first

Ozone has many low readings and a long tail of high ones. What sign does its skewnessSkewnessHow lopsided a distribution is; positive skew has a long right tail. have?

PositiveNear zeroNegative
Reveal

The answer: Positive

Positive: 1.24. The sign points to the long tail. As a rough guide, beyond about ±1\pm 1 is strong skew, and a mean no longer describes "typical".

03

Build intuition

Explore

Change a distribution's parameters and watch its skew and tails.

AExplorable · The distribution zoo

What do the common distributions look like, and when is a normal approximation good enough?

Which is larger for this distribution: the mean or the median?

How sure?

Family

2.0

μ, df, shape, α, meanlog, min, n or λ depending on the family.

1.5

σ, rate, scale, β, sdlog or width; for the binomial p = b/(b + 1).

mean

Solid: the distribution. Dashed: a normal with the same mean and SD.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

KurtosisKurtosisHow heavy a distribution's tails are compared with a normal; positive excess means more extreme values. describes the weight of the tails. CodeSplash reports excess kurtosis, so a normal distribution sits at 0. High values mean extreme values are more common than a normal curve would suggest.

04

Two peaks

Read

A column with two peaks usually means two populations mixed together. Old Faithful's eruptions are the classic case: short ones and long ones.

The dip test checks for more than one mode. Here the dip statistic is 0.092, p = .002, on 272 eruptions.

Modality — Hartigan's dip testRecorded · Python and R agreeRecorded 2026-11-17 · 9 values compared
R

Hartigan's dip test, D = 0.092, p = .002

Dip D
0.0924
p
0.0020
Bimodality coefficient
0.7692

Plots

Distribution of eruptionsHow is one numeric variable distributed?
View data
eruptions
3.600
1.800
3.333
2.283
4.533
2.883
4.700
3.600
1.950
4.350
1.833
3.917
4.200
1.750
4.700
2.167
1.750
4.800
1.600
4.250
1.800
1.750
3.450
3.067
4.533
3.600
1.967
4.083
3.850
4.433
4.300
4.467
3.367
4.033
3.833
2.017
1.867
4.833
1.833
4.783
4.350
1.883
4.567
1.750
4.533
3.317
3.833
2.100
4.633
2
4.800
4.716
1.833
4.833
1.733
4.883
3.717
1.667
4.567
4.317

First 60 of 272 rows.

Assumptions

  • Continuous values — The dip assumes a continuous variable; many ties (rounding, counts) make modes hard to judge.

Modality

MeasureValueReading
Hartigan's dip D0.0924more than one mode (p < .05)
p (uniform null)0.0020499 simulations
Sarle's bimodality coefficient0.7692above 5/9: possibly bimodal
Skewness (G1)−0.4182
Excess kurtosis (G2)−1.506
  • The dip is the largest distance between the data's ECDF and the closest unimodal distribution; its p-value compares it with uniform samples of the same size (the least favorable unimodal case, so the test is conservative).
  • Sarle's coefficient is a screening heuristic from skewness and kurtosis, not a test; heavy skew alone can push it above 5/9.
  • 146 tied value(s): ties are treated as infinitesimally separated (as diptest does).
The exact R script · R R version 4.5.1 (2025-06-13)
# Modality (Hartigan's dip test)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method distribution.modality 1.0.1 · spec a3a1987b3f540f5d
# Dataset: h_faithful (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/h_faithful.parquet", col_select = c("eruptions")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("eruptions")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("eruptions"))  # infinite values stop the run (registry/errors.yaml)

# %% Test
y <- "eruptions"
x <- as.numeric(df[[y]])
x <- x[is.finite(x)]
n <- length(x)
seed <- 42  # uniform null samples from the shared Wichmann-Hill stream
reps <- as.integer(499)
alpha <- 0.05
if (n < 4) cs_error("CS_E_TOO_FEW_ROWS", what = "The dip test", min = 4, n = n)
if (length(unique(x)) < 2) cs_error("CS_E_CONSTANT", column = y)  # one value: no distribution shape to judge, and skewness and kurtosis are 0 / 0
dt <- cs_dip_test(x, reps = reps, seed = seed)
d <- dt[1]
p <- dt[2]
bcv <- cs_bimodality_coefficient(x)
bc <- bcv[1]
bc_flag <- is.finite(bc) && bc > 5 / 9
ties <- n - length(unique(x))

# %% Result
values <- list(n = n, dip = d, p = p, bc = bc, bc_flag = bc_flag, skewness = bcv[2], kurtosis = bcv[3], reps = reps, ties = ties)
multi <- p < alpha
summary <- paste0(sprintf("Hartigan's dip for %s: D = %.4f, %s (%d uniform samples, seed %d) — ", y, d, cs_fmt_p(p), reps, as.integer(seed)),
                  if (multi) "evidence of more than one mode." else "no evidence against a single mode.",
                  if (is.finite(bc)) sprintf(" Sarle's bimodality coefficient is %.3f, %s the 5/9 ≈ 0.556 benchmark.", bc, if (bc_flag) "above" else "below") else "")
notes <- list("The dip is the largest distance between the data's ECDF and the closest unimodal distribution; its p-value compares it with uniform samples of the same size (the least favorable unimodal case, so the test is conservative).",
              "Sarle's coefficient is a screening heuristic from skewness and kurtosis, not a test; heavy skew alone can push it above 5/9.")
if (ties > 0) notes[[length(notes) + 1]] <- sprintf("%d tied value(s): ties are treated as infinitesimally separated (as diptest does).", as.integer(ties))
cs_publish(list(
  method = "distribution.modality",
  methodVersion = "1.0.1",
  title = "Modality — Hartigan's dip test",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = sprintf("Hartigan's dip test, D = %.3f, %s", d, cs_fmt_p(p)),
  statistics = list(list(key = "dip", label = "Dip D", value = d), list(key = "p", label = "p", value = p), list(key = "bc", label = "Bimodality coefficient", value = bc)),
  tables = list(list(key = "modality", title = "Modality", columns = list(
    list(key = "measure", label = "Measure", type = "string"), list(key = "value", label = "Value", type = "number"),
    list(key = "reading", label = "Reading", type = "string")), rows = list(
    list(measure = "Hartigan's dip D", value = d, reading = if (multi) "more than one mode (p < .05)" else "consistent with one mode"),
    list(measure = "p (uniform null)", value = p, reading = sprintf("%d simulations", reps)),
    list(measure = "Sarle's bimodality coefficient", value = bc, reading = if (bc_flag) "above 5/9: possibly bimodal" else "below 5/9"),
    list(measure = "Skewness (G1)", value = bcv[2], reading = ""), list(measure = "Excess kurtosis (G2)", value = bcv[3], reading = "")))),
  effectSizes = list(),
  assumptions = list(list(key = "continuous", label = "Continuous values", status = if (ties > n %/% 4) "warn" else "info",
                          detail = "The dip assumes a continuous variable; many ties (rounding, counts) make modes hard to judge.")),
  warnings = warnings,
  notes = notes,
  charts = list(cs_chart("hist", "histogram", sprintf("Distribution of %s", y), list(x = cs_col(y, x)), controls = list(kde = TRUE))),
  values = values
))
Python

Hartigan's dip test, D = 0.092, p = .002

Dip D
0.0924
p
0.0020
Bimodality coefficient
0.7692

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Continuous values — The dip assumes a continuous variable; many ties (rounding, counts) make modes hard to judge.

Modality

MeasureValueReading
Hartigan's dip D0.0924more than one mode (p < .05)
p (uniform null)0.0020499 simulations
Sarle's bimodality coefficient0.7692above 5/9: possibly bimodal
Skewness (G1)−0.4182
Excess kurtosis (G2)−1.506
  • The dip is the largest distance between the data's ECDF and the closest unimodal distribution; its p-value compares it with uniform samples of the same size (the least favorable unimodal case, so the test is conservative).
  • Sarle's coefficient is a screening heuristic from skewness and kurtosis, not a test; heavy skew alone can push it above 5/9.
  • 146 tied value(s): ties are treated as infinitesimally separated (as diptest does).
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Modality (Hartigan's dip test)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method distribution.modality 1.0.1 · spec a3a1987b3f540f5d
# Dataset: h_faithful (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import math

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.stats import distribution as csd

# %% Data
df = pd.read_parquet("tests/parity/fixtures/h_faithful.parquet", columns=["eruptions"])
n_input = len(df)
df = df.dropna(subset=["eruptions"])  # listwise deletion over the analysis columns
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["eruptions"])  # infinite values stop the run (registry/errors.yaml)

# %% Test
y = "eruptions"
x = df[y].to_numpy(dtype=float)
x = x[np.isfinite(x)]
n = x.size
seed, reps = 42, int(499)  # uniform null samples from the shared Wichmann–Hill stream
alpha = 0.05
if n < 4:
    cs.cs_error("CS_E_TOO_FEW_ROWS", what="The dip test", min=4, n=n)
if len(np.unique(x)) < 2:  # one value: no distribution shape to judge, and skewness and kurtosis are 0 / 0
    cs.cs_error("CS_E_CONSTANT", column=y)
d, p = csd.dip_test(x, reps=reps, seed=seed)
bc, g1, g2 = csd.bimodality_coefficient(x)
bc_flag = bool(np.isfinite(bc) and bc > 5 / 9)
ties = int(n - np.unique(x).size)

# %% Result
values = {"n": n, "dip": d, "p": p, "bc": bc, "bc_flag": bc_flag, "skewness": g1, "kurtosis": g2, "reps": reps, "ties": ties}
multi = p < alpha
summary = (f"Hartigan's dip for {y}: D = {d:.4f}, {cs.fmt_p(p)} ({reps} uniform samples, seed {seed}) — "
           + ("evidence of more than one mode." if multi else "no evidence against a single mode.")
           + (f" Sarle's bimodality coefficient is {bc:.3f}, {'above' if bc_flag else 'below'} the 5/9 ≈ 0.556 benchmark." if np.isfinite(bc) else ""))
notes = ["The dip is the largest distance between the data's ECDF and the closest unimodal distribution; its p-value compares it with uniform samples of the same size (the least favorable unimodal case, so the test is conservative).",
         "Sarle's coefficient is a screening heuristic from skewness and kurtosis, not a test; heavy skew alone can push it above 5/9."]
if ties:
    notes.append(f"{ties} tied value(s): ties are treated as infinitesimally separated (as diptest does).")
cs.publish({
    "method": "distribution.modality",
    "methodVersion": "1.0.1",
    "title": "Modality — Hartigan's dip test",
    "engine": cs.engine_info("pandas", "numpy"),
    "n": n,
    "summary": summary,
    "apa": f"Hartigan's dip test, D = {d:.3f}, {cs.fmt_p(p)}",
    "statistics": [{"key": "dip", "label": "Dip D", "value": d}, {"key": "p", "label": "p", "value": p}, {"key": "bc", "label": "Bimodality coefficient", "value": bc}],
    "tables": [{"key": "modality", "title": "Modality", "columns": [
        {"key": "measure", "label": "Measure", "type": "string"}, {"key": "value", "label": "Value", "type": "number"},
        {"key": "reading", "label": "Reading", "type": "string"}], "rows": [
        {"measure": "Hartigan's dip D", "value": d, "reading": "more than one mode (p < .05)" if multi else "consistent with one mode"},
        {"measure": "p (uniform null)", "value": p, "reading": f"{reps} simulations"},
        {"measure": "Sarle's bimodality coefficient", "value": bc, "reading": "above 5/9: possibly bimodal" if bc_flag else "below 5/9"},
        {"measure": "Skewness (G1)", "value": g1, "reading": ""}, {"measure": "Excess kurtosis (G2)", "value": g2, "reading": ""}]}],
    "effectSizes": [],
    "assumptions": [{"key": "continuous", "label": "Continuous values", "status": "warn" if ties > n // 4 else "info",
                     "detail": "The dip assumes a continuous variable; many ties (rounding, counts) make modes hard to judge."}],
    "warnings": warnings,
    "notes": notes,
    "charts": [cs.chart("hist", "histogram", f"Distribution of {y}", {"x": cs.col(y, x)}, controls={"kde": True})],
    "values": values,
})

The mean of a bimodal column describes almost no actual value. Look for the variable that separates the peaks.

05

Bins can fool you

Explore

The same data can look smooth, spiky or two-humped depending on the bin width.

AExplorable · Bins and bandwidth

How do histogram bins and smoothing bandwidth change the story the same data tell?

How many humps does the population really have?

How sure?
2.6
150
12
1.00

Bars: histogram with your bins. Line: kernel density with your bandwidth.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Try two or three bin widths before believing a shape. A density curve has the same issue with its bandwidth.

06

In the app

In the app

In Insights (⌘5), click a numeric column. Its page shows the histogram, the Normality panel, findings such as skew or more than one mode, and Which distribution is this?, which ranks candidate families by AIC.

Each finding offers a next step, such as a test in Analyze or a fix in Prepare.

07

Check your understanding

Checkpoint

Check yourself

A column has mean 40 and median 55. What does that suggest?

Show the answer

Answer: b

The mean is pulled toward the long tail. Here it sits below the median, so the longer tail is on the left.

Check yourself

A histogram of patient recovery times shows two clear peaks. What is the most useful next step?

Show the answer

Answer: b

Two peaks usually mean two populations. Finding what separates them is the analysis, and a transformation would hide it.

Check yourself

Excess kurtosis of 5 tells you what?

Show the answer

Answer: a

Kurtosis measures tail weight. It says nothing about the number of peaks or the direction of a skew.

08

Recap

Recap
  • Look first: symmetry, tails and peaks.
  • Skewness points toward the long tail, and kurtosis measures tail weight.
  • Two peaks suggest two populations, so go and find what separates them.

Concepts in this lesson