Statistics & probability

Hartigan dip test calculator for unimodality

Enter ten through three hundred finite measurements from the population whose distributional shape you want to examine.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Enter ten through three hundred finite measurements from the population whose distributional shape you want to examine. The procedure sorts values internally, so row order has no meaning. Independence matters: a dense time series or many repeated measurements from a few people can make the nominal calibration misleading even though the entered list looks large and passes every numeric check.

THE FORMULAD=inf over unimodal CDFs U of sup_x |F_n(x)−U(x)|; p_MC=(1+#{D_uniform≥D_observed})/(B+1).

A worked example

Values0,.1,.2,.3,.4,4,4.1,4.2,4.3,4.4 give Hartigan dip0.225.

Good to know

10–300 IID continuous observations, seeded uniform-null Monte Carlo B=1000–5000 and n*B<=500000. Correct greatest convex minorant/least concave majorant dip algorithm; report conservative uniform calibration and simulation uncertainty. Ties flagged as discrete-data calibration limitation; no number-of-modes estimate or mixture fitting.

Use independent observations on a continuous scale

Enter ten through three hundred finite measurements from the population whose distributional shape you want to examine. The procedure sorts values internally, so row order has no meaning. Independence matters: a dense time series or many repeated measurements from a few people can make the nominal calibration misleading even though the entered list looks large and passes every numeric check.

The dip asks whether the empirical distribution is compatible with a unimodal population distribution. It does not fit normal mixtures or estimate the number of modes. Distinct modes depend on the underlying distribution rather than a chosen histogram bin width, which makes this a useful complement to exploratory plots. Transformations must be considered carefully because a nonlinear change of measurement scale can change modality.

The statistic measures cumulative probability discrepancyDip: closest unimodal cumulative approximationvertical CDF gapMeasurement value; default dip = 0.225
Scroll across to see the full diagram.
Empirical staircase with a schematic unimodal approximation; the independent default dip is0.225.

Compare this with the Gaussian mixture density fit calculator with component responsibilities. Computes empirical-CDF distance from the closest unimodal CDF and tests unimodality, rather than selecting or fitting a Gaussian mixture. No existing page computes dip.

A distance from the unimodal distribution class

The dip statistic is the smallest maximum vertical discrepancy between the empirical cumulative distribution and a unimodal cumulative distribution. Unimodality constrains the cumulative curve to be convex before a modal region and concave afterward. The statistic searches over that class instead of comparing only with a fitted Gaussian curve, so a nonnormal yet unimodal distribution can remain compatible with the null.

A larger dip means a larger unavoidable discrepancy from every unimodal cumulative representation of the sample. Its scale is probability, not the units of the observations. It is invariant to translating all measurements or multiplying by a positive constant. A small dip does not prove there is exactly one scientific subpopulation, because different mechanisms or mixture components can still generate a unimodal marginal distribution.

Compute hulls and simulate a uniform reference

The calculation uses greatest-convex-minorant and least-concave-majorant constructions and updates a candidate modal interval. A simple maximum gap between two hulls computed once is not the full dip algorithm. Ties and endpoint conventions need consistent treatment to match the established statistic. The result should agree with an independently maintained dip implementation, not merely with a visually plausible separation in a histogram.

For inference the page simulates uniform samples of the same size, recomputes their dip statistics, and compares them with the observed value. Uniform calibration is the standard conservative reference over the unimodal null class. The plus-one Monte Carlo tail prevents a zero p from a finite run. The seed, simulation count, and sampling uncertainty should accompany the result.

Two tight groups give a large example dip

The ten default observations are 0, 0.1, 0.2, 0.3, 0.4, 4, 4.1, 4.2, 4.3, and 4.4. Each of two tight groups contains five observations and the intervening gap is large. An independent compiled implementation gives dip exactly 0.225 for these values. No histogram bins or mixture model parameters are needed to compute that number.

A seeded simulation p is a separate output and may vary between implementations using different random generators. With one thousand simulations, the plus-one probability resolution is about one thousandth. An extreme sample may produce no exceedances, which still gives a positive estimated tail. Interpret such a result as limited by simulation resolution rather than as an exact probability or proof of two underlying populations.

Read the cumulative-distribution geometry

The static drawing shows an empirical staircase and a candidate unimodal cumulative curve. Vertical distances are measured in cumulative probability; horizontal gaps reflect measurement units. A long interval containing no observations can force a tension between the required convex and concave parts of a unimodal approximation, which helps explain why the two-cluster example has a substantial dip.

The marked modal interval is an algorithmic feature of a closest unimodal representation. It should not be read as an estimated confidence interval for a unique mode or as a clinical cutoff separating subjects. Likewise, the dip's magnitude does not directly tell how many peaks a smooth density estimate would display. Those are different estimation problems with their own bandwidth and modeling choices.

Ties and simulation limits need disclosure

The reference is intended for IID continuous observations. Rounded measurements or genuinely discrete outcomes can create ties and alter calibration; the calculator flags this limitation instead of silently pretending the data are continuously sampled. Small samples also have limited power to detect modest secondary peaks. A non-significant result can therefore coexist with an interesting-looking histogram without proving that the visual impression is either correct or mistaken.

The simulation count is one thousand through five thousand and n times that count cannot exceed five hundred thousand. Monte Carlo uncertainty is largest for p-values in the middle of the probability range and remains relevant near decision thresholds. Increasing simulations reduces that uncertainty but does not solve dependence, rounding, or a question framed around a discrete count distribution.

Use a shape test for a shape question

Normality tests evaluate agreement with a particular distributional family and can reject for skewness or tail behavior in a perfectly unimodal population. The dip instead targets departure from unimodality. A two-component Gaussian mixture fit estimates a model and can allocate several components to a single broad peak. Neither a normality p nor a mixture component count is a substitute for the dip's null hypothesis.

Keep the measurement scale, sampling unit, sample size, tie status, dip, uniform-null simulation count, seed, estimated p, and simulation uncertainty in a report. If the result motivates further analysis, examine the observations and collection process before naming distinct groups. The calculator provides evidence about marginal distribution shape; it cannot establish the biological, behavioral, or physical mechanism responsible for that shape.

A few questions, answered

Does dip count the number of modes?

No. It measures discrepancy from unimodality and does not estimate a peak count or mixture component count.

What reference distribution is simulated?

IID continuous uniform samples of the same size, using the standard conservative uniform-null calibration.

Can rounded data affect the test?

Yes. Ties limit the continuous-data calibration and are flagged.

Why is p never zero?

A plus-one Monte Carlo tail includes the observed arrangement and remains positive when no simulated statistic exceeds it.

Find your calculator

Start typing to explore the library.