Statistics & probability

Ripley K and L function calculator for points in a rectangular window

Measure homogeneous point-pattern pair structure with translation-corrected K and L curves in a rectangular observation window.

Your numbers

One distinct point per row, inside the observation rectangle.
The observation window is part of the point-pattern model.
Nonnegative radii strictly below half the shorter window side.

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

Measure homogeneous point-pattern pair structure with translation-corrected K and L curves in a rectangular observation window.

THE FORMULAK̂(r)=A²/[n(n−1)] Σ_{i≠j} 1(d_ij≤r)/[(w−|Δx|)(h−|Δy|)]; L̂(r)=sqrt[K̂(r)/π].

A worked example

The default six points in a 10 by 10 window give K(1)=29.62962963 and L(1)−1≈2.071059106 under the stated finite-pair normalization.

Good to know

3–500 distinct points in a positive rectangle; up to 60 increasing radii below half the shorter side. Translation edge correction with explicit n(n−1) pair normalization. Homogeneous stationary comparison only; no arbitrary windows, inhomogeneity correction, envelopes, p-values or causal clustering claim.

Pair structure differs from local density

A map with many points in one region may reflect genuine interaction, a varying background intensity, an observation boundary or sampling rules. Ripley’s K summarizes how many other points lie within a given radius of a typical point, after a stated edge correction and normalization. It is a second-order summary of a point pattern.

A kernel density estimate answers a different question about the spatial distribution of individual observations. A high density region need not imply interaction between points after accounting for background variation. This page uses a homogeneous reference, so it does not remove an unknown intensity gradient or automatically distinguish those explanations.

Ripley K and L function calculator for points in a rectangular window worked exampleWindow area A = 1004 pairs at radius 1K(1) ≈ 29.62963L(1) − 1 ≈ 2.07106
Scroll across to see the full diagram.
The default six points in a 10 by 10 window give K(1)=29.62962963 and L(1)−1≈2.071059106 under the stated finite-pair normalization.

Compare this with the Kernel density estimate calculator with bandwidth selection. Measure pairwise spatial clustering relative to a homogeneous point-process benchmark across radii; a KDE estimates first-order marginal density and does not correct pair counts for observation-window edges.

Define the rectangle before comparing radii

The observation window describes where points could have been recorded, including empty parts of the region. Enter its minimum and maximum coordinates rather than allowing the observed point extrema to define it silently. Enlarging a window without adding points changes the intensity estimate and therefore changes the scale of the K estimate.

Coordinates and radii must share one distance unit. The rectangle must have positive width and height, and every point must lie inside it. Repeated coordinates are rejected because coincident events need a separately stated multiplicity model. The supported radius range stays below half the shorter window side to avoid very unstable large-scale edge weights.

Correct pairs using translated overlap

Two points separated by displacement dx,dy can both be observed only where the window overlaps a translated copy of itself. For an axis-aligned rectangle that overlap is the product of width minus absolute dx and height minus absolute dy. Pairs with smaller overlap receive larger inverse-overlap weights.

The implementation counts ordered pairs conceptually, or twice each unordered pair computationally. It uses the explicit finite-pair normalization A squared divided by n times n minus one. Some references or packages use an intensity-squared estimate with n squared instead; that convention changes finite-sample values and must be matched before comparing outputs.

Read K, L and the Poisson benchmark

Under a homogeneous planar Poisson reference, K at radius r is pi times r squared. Transforming K to L by taking the square root of K divided by pi places the benchmark on the line L equals r. Subtracting r makes a zero reference easier to see across different radii.

Positive L minus r indicates more nearby weighted pairs than the homogeneous benchmark at that radius, while negative values indicate fewer. These are descriptive deviations, not significance decisions. A single extreme point on the curve cannot be interpreted as a p-value, and nearby radii are strongly dependent because they repeatedly count many of the same pairs.

Trace the default pair count

The default has two small groups of three points in a ten-by-ten window. At radius one, four unordered pairs fall within the threshold. Their translation overlaps are each ninety square units, so doubling the four inverse-overlap weights and applying A squared over thirty gives K approximately 29.62962963.

Taking the square root after dividing by pi gives L approximately 3.071059106, hence L minus r approximately 2.071059106. The pair table’s threshold includes distances equal to the radius. This inclusion rule is useful when a worked example deliberately contains unit-distance pairs, as this default does.

Radii are an analysis scale choice

A radius grid should reflect the spatial scales relevant to the observations and the resolution of coordinate recording. A dense grid may draw a smooth-looking curve without supplying more independent evidence. Here radii must increase strictly, and the result lists the count entering each cumulative threshold alongside corrected values.

Very large inverse-overlap weights can make edge-corrected estimates unstable even when their formulas are valid. Restricting radii reduces one source of instability but does not create a confidence band. Point counts, window design and the scientific sampling process still determine what scale of pattern can be interpreted responsibly.

What this calculation cannot establish

The page does not fit a spatial model, simulate reference envelopes or test a composite null hypothesis with estimated parameters. It does not support polygonal windows, missing interior regions, directional anisotropy or spatially varying intensity corrections. A rectangle containing unobserved holes should not be supplied as though every location were equally observable.

For a basic verification, translate every point and both rectangle corners by the same vector: all results must remain unchanged. Scaling coordinates and radii by a factor scales K by its square and L by the factor. These geometric identities check the implementation while preserving the distinction between descriptive arithmetic and statistical evidence.

A few questions, answered

Does positive L minus r prove clustering?

No. It is a descriptive departure from a homogeneous benchmark; significance requires an appropriate model and calibrated comparison such as simulation envelopes.

Why may another package give a slightly different K?

Finite-pair n(n−1) normalization differs from an n² intensity normalization. Match that convention and the edge correction before comparing.

Can I infer the window from the point extrema?

Not automatically. The observation window must describe where points could have been recorded, including genuinely observed empty space.

Are repeated coordinates allowed?

No. Coincident-event multiplicities need a separate counting model and are rejected by this implementation.

Find your calculator

Start typing to explore the library.