Comparing two σ-profiles with distances that make sense
Compare σ-profiles with an area-normalised L2 or a one-dimensional Wasserstein distance, computed on identical bins from the same recipe. Here is how.
Updated November 28, 2026
The sensible distances between two σ-profiles are the Euclidean distance between area-normalised histograms, which is quick and simple, and the one-dimensional Wasserstein distance, which respects the fact that σ is an ordered axis. Both require the two profiles to be built on identical bins from the same DFT recipe, and both must be computed on profiles of the same kind, raw or averaged, never one of each. This guide gives both in numpy and says when each helps.
First, make the two histograms comparable
A distance is only as meaningful as the two objects it compares. Before any arithmetic, check four things.
- Same recipe. Functional, basis set, cavity radii and dielectric constant all shift the histogram. Read the method block of each file, see what a DFT recipe is.
- Same kind of σ. The values in a .mfsig file are raw per-segment screening charge densities. An averaged σ-profile from a COSMO-RS style workflow is a smoothed object. A distance between a raw and an averaged profile measures the smoothing, not the chemistry.
- Same bins. Use one grid for both, the conventional -0.03 to +0.03 e/Ų in 0.001 steps, see the binning guide.
- Same normalisation. Divide each histogram by its total area if you want to compare shapes, keep absolute areas if size is part of the question.
With these settled, the two histograms are vectors p and q of equal length, and a distance is a function of the pair.
The L2 distance, and what it misses
The Euclidean or L2 distance is the square root of the sum of squared bin differences. It is symmetric, fast and has a clear meaning as the length of the difference vector. For normalised profiles it lies between zero and the square root of two.
Its weakness is that bins are treated as unrelated categories. Two profiles with the same peak shifted by one bin, 0.001 e/Ų apart, are as far apart as two profiles with peaks at opposite ends of the axis. For sigma profiles that is wrong. A peak at 0.012 and a peak at 0.013 e/Ų describe nearly the same acceptor. Small conformer differences and small recipe differences shift peaks by a bin or two, and L2 punishes them as if they were new chemistry.
The Wasserstein distance, area that has to move
The one-dimensional Wasserstein-1 distance, also called the earth mover's distance, asks how much area must be moved, and how far along the σ axis, to turn one normalised profile into the other. A peak shifted by one bin costs one bin width times the area moved. A peak shifted by twenty bins costs twenty times as much. In one dimension it has a closed form, the integral of the absolute difference between the two cumulative distributions, which is a few lines of numpy. SciPy also provides it as scipy.stats.wasserstein_distance.
The result has the units of σ, e/Ų, and reads as an average displacement of surface along the σ axis. A value of 0.001 e/Ų says the two surfaces differ by about one bin on average. That is a physically interpretable number, which is why the Wasserstein distance is the better default for similarity searches such as green solvent substitution.
Moments, a three-number comparison
The σ-moments in a .mfsig file, variance, skewness and excess kurtosis, compress each profile into three numbers, and the total surface area adds a fourth. Comparing these is cruder than comparing histograms but far more interpretable. Two solvents with similar variance have similar overall polarity. A skewness difference says that one has more donor than acceptor surface relative to the other. The σ-moments as descriptors guide develops this reading. Use moments to explain a histogram distance, not to replace it.
A worked example, methanol against ethanol and hexane
import numpy as np
edges = np.arange(-0.030, 0.030 + 1e-9, 0.001)
widths = np.diff(edges)
def profile(doc):
seg = doc[SEGMENT_KEY] # names: see /anatomy
sigma = np.array([s[SIGMA_KEY] for s in seg])
area = np.array([s[AREA_KEY] for s in seg])
p, _ = np.histogram(sigma, bins=edges, weights=area)
return p / p.sum() # shape only
def l2(p, q):
return float(np.sqrt(((p - q) ** 2).sum()))
def wasserstein(p, q):
cdf_gap = np.abs(np.cumsum(p) - np.cumsum(q))
return float((cdf_gap * widths).sum()) # e/Å^2
p_meoh, p_etoh, p_hex = (profile(d) for d in (meoh, etoh, hexane))
print("MeOH-EtOH L2 %.3f W1 %.5f" % (l2(p_meoh, p_etoh), wasserstein(p_meoh, p_etoh)))
print("MeOH-hexane L2 %.3f W1 %.5f" % (l2(p_meoh, p_hex), wasserstein(p_meoh, p_hex)))Expect both distances to rank hexane as farther from methanol than ethanol is. Expect the ratio between the two pairs to be larger for the Wasserstein distance, because methanol and ethanol share polar peaks at nearly the same σ while hexane has none, and the Wasserstein distance charges for the whole journey of that polar area towards zero. Exact values depend on the recipe and the conformer, so compute them for your own files rather than quoting them.
Choosing between them
Use L2 when you need a quick sanity check or a kernel for a model trained on one recipe. Use the Wasserstein distance when you rank candidates for substitution or search a library by similarity. Use moments to explain the ranking to a colleague. And whatever the distance, keep absolute total area as a separate number, since a normalised histogram has forgotten whether the molecule is small or large, and size matters for every contact-based model.
Key points
- Compare only profiles from one recipe, of one kind, raw or averaged, on one grid, with one normalisation.
- L2 is quick and simple but treats a one-bin shift as a total change.
- The Wasserstein distance respects the σ axis, reads in e/Ų as an average displacement of surface, and is the better default for similarity.
- σ-moments and total area explain a distance in physical terms. Use them alongside, not instead.
- Compute distances for your own files rather than quoting numbers, since they depend on recipe and conformer.
Questions people ask
- What is the simplest meaningful distance between two σ-profiles?
- The Euclidean distance between the two histograms after normalising each by its total area, on the same bins. It is quick, symmetric and easy to explain. Its weakness is that a peak shifted by one bin counts as fully different, which the Wasserstein distance corrects.
- Why does the Wasserstein distance suit σ-profiles?
- Because σ is an ordered axis. Moving area from 0.010 to 0.011 e/Ų is a small change in chemistry, and the Wasserstein distance charges it a small cost, proportional to the shift. A bin-by-bin distance charges the full amount regardless of how far the area moved.
- Can I compare a σ-profile from MFsig with one from another program?
- Only with care. Functional, basis set, cavity radii and dielectric constant all move the histogram, and a raw per-segment profile is not comparable to an averaged one. Compare within one recipe, and treat cross-recipe distances as indicative only.
Further reading
In practice: A .mfsig file is JSON and reads with the standard library. Ordering is done on the site or through the API described in the docs, and AI agents can read the published samples through the MCP server at /mcp.
Generate a σ-profile from your SMILES
Free converter for a profile you already have, a reference-grade DFT run with its provenance record when it has to be defensible.