# Analysing Spatial Heterogeneity using Optimal Transport

Joseph Touzet, Xavier Bacon

► To cite this version:

Joseph Touzet, Xavier Bacon. Analysing Spatial Heterogeneity using Optimal Transport. 2025. hal-05425711

HAL Id: hal-05425711

https://hal.science/hal-05425711v1

Preprint submitted on 19 Dec 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Analysing Spatial Heterogeneity using Optimal Transport

Joseph Touzet¹ and Xavier Bacon¹

¹École Normale Supérieure de Paris-Saclay

December 8, 2025

## Abstract

The article presents a general method based on optimal transport theory for quantifying spatial heterogeneity in group distributions. Three indices are proposed allowing for a multi-scale analysis. The global index extends the one introduced by various authors in the study of spatial or temporal concentration. From it, we derive two local indices: an non-negative and a signed indices, which both arise from the optimal coupling of the observed distributions with a null distribution which we defined. We discuss the choice of the optimal coupling among the many possible ones, and its impact on the sensitivity of our local indices to different situations of heterogeneity. All these indices take strongly into account the entire spatial structure of the group distributions. Moreover, all these indices have the advantage to be expressed in meaningful units (meters, travel time), making them easier to interpret. To illustrate the method, numerical applications are made on the first round of the 2022 French presidential election results in Paris, where the city is divided into units corresponding to polling stations while groups represent running candidates.

# 1 Introduction

## 1.1 Context

Given several spatial distributions of individuals, measuring dissimilarities between them has been the focus of a significant amount

of research in recent decades. Historically, it emerged from the need of understanding how social groups occupy and share the same space and has its roots in urban studies on racial segregation [1, 13] in U.S. cities.

More recently, the idea of measuring the spatial disparity of fixed groups has been extended to many other situations and so has been the topic of various studies where groups are defined by their gender, social income, education level and so on. For a complete review of these advances, the interested reader may refer to [15, 2, 20, 5, 12, 18].

To address this issue, one way is to propose an index which aims to characterize the whole situation in terms of heterogeneity between the different groups. At this point many indices have been proposed, because it is now evident that heterogeneity manifests in multiple dimensions (evenness, exposure, concentration, centralization and clustering [9]) and cannot be adequately captured by a single criterion, it is essential to notice that researchers do not expect to find an index better in every situation but rather that each situation should have its own appropriate index. In other words, an index may be well-suited to measure a given situation but inadequate for measuring the others.

The quantification of heterogeneity typically requires the choice of a spatial scale of analysis, from a local perspective to the global system-level. As a consequence, when quantifying heterogeneity, one typically chooses between local and global indices [2], each capturing a specific scale: the unit-level situation in the case of local indices, or the global-level situation in the
case of global indices. Since each scale captures distinct information on the underlying spatial pattern, a phenomenon can be of great importance at the local level, while becoming almost invisible at a larger scale. Indices that incorporate the multiscale nature of heterogeneity such as the one we propose in this paper are a more recent development [5].

The multitude of proposed indices differ in terms of the properties they have. Among all these properties, one is called the spatiality and refers to the sensitivity of the index to any population spatial rearrangement. In order to clarify, let us fix the classical framework and consider a space $\mathcal{X}$ defined as the union of areal units $x_1, \dots, x_I$ where individuals of different groups are distributed. Typically, in this context, such an index would be sensitive to any permutation of populations between two units. On the contrary, the dissimilarity index and the Theil index are aspatial [15]. For these two indices, the spatial distribution of the population does not really matters except in the composition of each unit where individuals are grouped. However, the spatial arrangement of the units themselves is ignored.

Referring to [5], one way to incorporate space into aspatial index is to use weighted spatial averages of population counts rather than single unit counts. Another approach consists in structuring the space of spatial units by proposing an aggregation process based on a nearest neighbor process. In some sense, this can be seen as a *topologization* of the set of areal units $\mathcal{X}$ by defining the set of neighborhoods in it. Both of these aspects are incorporated into our indices.

To propose a spatial index, our approach is to rely on optimal transport theory, which aims to determine the most efficient way to transfer one spatial distribution onto another. For this purpose, we select a group and compare *via* the optimal transport distance its individuals' distribution with a null distribution $\bar{\alpha}$ corresponding to a perfectly homogeneous spatial arrangement of the same number of individuals. For a complete presentation of the optimal transport framework and a discussion about this null distribution, see subsections 1.2 and 2.1 of this

article.

In the optimal transport framework, the spatial aspect of the problem is taking into account by introducing a distance-cost matrix $C$, which gives the cost associated to *move* an infinitesimal amount from one areal unit to another: if we consider the areal units as nodes of a complete graph, then the edge weight between two given nodes $x$ and $y$ will be defined by $C(x, y)$. The introduction of the distance-cost matrix is a form of *topologization* of $\mathcal{X}$ the space of spatial units, since by specifying the distances between them, we also define the neighborhood of each unit.

The use of the optimal transport framework to characterize concentration phenomena was already proposed in [6, 11, 8, 3], where the authors focus on a single distribution (spatial in [6, 11, 3] and temporal in [8]) and propose a global index based on the minimization of the cost of transferring the amount of the phenomenon of interest from over-average to under-average regions.

Compared with the cited works, our study focuses on the spatial heterogeneity of multiple distributions, from which we derive both local and global indices. Although our indices can be applied to a single distribution compared to a null one, the comparison is not necessarily made with a constant in space distribution but with a more general distribution $\bar{\alpha}$ (subsection 2.1). Also in our case, the optimal transport framework operates on the entire distribution rather than only on over-average or under-average regions. As we will see, depending on the distance-cost matrix, it can be sometimes more efficient to move all the individuals, even if they belong to under-average regions: readers unfamiliar with optimal transport might assume that, given two distributions (say) $\alpha$ and $\beta$ and a cost $C$, the optimal transport problem between $\alpha$ and $\beta$ reduces to the optimal transport problem between the subdistribution of $\alpha$ surplus with respect to $\beta$ and the $\beta$ surplus with respect to $\alpha$. This, however, is not true in general. In fact, the property holds when the cost $C$ is a distance (in the sense it satisfies the triangular inequality), but it fails in general. We will come back to these major aspects in
subsection 3.1 (in particular Example 1).

This article is organised as follows. We briefly present the optimal transport framework in this section. In section 2, we introduce our model in detail. First, the global index, followed by the local indices. In short, our index indicates the distance individuals would need to move if they wished to, broadly speaking, desegregate the situation. In section 3, we first have a discussion about the Euclidean cost we consider and its convex and concave approximation and to understand how our various indices are sensitive to the different dimensions of heterogeneity mentioned above, we have included numerous examples and simulations to give to the reader additional insight. Finally we end this section with an analysis of heterogeneity in electoral results. For that purpose, we compute the different indices on the first round of the 2022 French presidential election results in Paris, where the city is divided into units corresponding to polling stations while groups represent votes for the running candidates.

## 1.2 A brief reminder of optimal transport

Before describing the model itself, we need to recall a few elements about optimal transport theory. For a literature review from the founding articles [10], [7] to current advance, the interested reader may look at [14], [17], [19], [4].

The theory of optimal transport is concerned with finding the most efficient way to transport the so-called source distribution $\alpha$ to the so-called target distribution $\beta$, minimizing the total cost of transportation. So, let

$$ \alpha = \sum_{i=1}^{I} a_i \delta_{x_i}, $$

$$ \beta = \sum_{j=1}^{I} b_j \delta_{x_j}, $$

be two discrete probability measures on $\mathcal{X}$ endowed with a cost matrix $C = (C_{ij})$. The optimal transport problem is given as a minimization problem given by

$$ \inf \{ \langle C, P \rangle : P \in U(\mathbf{a}, \mathbf{b}) \} \quad (1) $$

where the constraint set $U(\mathbf{a}, \mathbf{b})$ is defined as

$$ U(\mathbf{a}, \mathbf{b}) = \{ \mathbf{P} \in \mathbb{R}_{+}^{I \times I}, \mathbf{P} \perp_I = \mathbf{a}, \mathbf{P}^T \perp_I = \mathbf{b} \} $$

and corresponds to the set of couplings between $\mathbf{a}$ and $\mathbf{b}$.

It is important to notice that (1) is nothing less than a minimization problem of a linear function on finite dimension subject to linear constraints and consequently admits a solution in the sense that there always exists $\mathbf{P}^*$ such that the infimum is attained. However the uniqueness of such a $\mathbf{P}^*$ is not satisfied in the general case. When there are more than one solution, a choice among all these optimal couplings can be made (notice that the total cost is by definition independent of that choice).

# 2 The model

## 2.1 Global heterogeneity index

We introduce a general framework to quantify the spatial heterogeneity of several distributions across a finite set of areal units. Let there be $N$ distinct groups, each spatially distributed over $I$ localized units or coordinates $x_1, \dots, x_I \in \mathbb{R}^d$ with $d \in \mathbb{N}^*$, indexed by $i = 1$. We denote by $\mathcal{X}$ the union of these units.

Let $A_i(n) \in \mathbb{R}_+$ be a quantity (amount of mass, number of individuals, etc.) of group $n$ observed in the areal unit $i \in I$. To represent to relative spatial concentration of group $n$ across the whole space, we introduce $\alpha(n)$ the normalized spatial distribution of group $n$ defined as

$$ \alpha(n) = \sum_{i=1}^{I} a_i(n) \delta_{x_i} $$

where

$$ a_i(n) = \frac{A_i(n)}{\sum_{i'=1}^{I} A_{i'}(n)} $$

denotes the fraction of group $n$ localized in $i$. This leads us to $N$ probability distributions representing each the spatial distribution of the group $n$ across $\mathcal{X}$.
To quantify how spatially heterogeneous these $N$ distributions are, we compare each of them to a null distribution $\bar{\alpha}$, referred as the *null distribution* and given by

$$ \bar{\alpha} = \sum_{i=1}^{I} \bar{a}_i \delta_{x_i} $$

where

$$ \bar{a}_i = \frac{\sum_{n=1}^{N} A_i(n)}{\sum_{i'=1}^{I} \sum_{n=1}^{N} A_{i'}(n)} $$

The null distribution $\bar{\alpha}$ plays a central role in our framework: it consists in defining distribution considered as completely homogeneous and taking this situation as a reference against which every other empirical distributions are compared.

In order to clarify the meaning of such this *null distribution*, consider, for example, two groups distributed across $\mathcal{X}$. Assume that the first group represents one-third of the total individuals, while the second group represents the remaining two-thirds. Then, for group 1, the null distribution in terms of individuals corresponds to a situation where, in each spatial unit, one-third of the individuals belong to the group 1. For the group 2, it corresponds to two-thirds of the individuals. When considered in terms of normalized distributions rather than absolute individual counts, this aligns precisely with the definition given above. The reason behind this normalization is the later comparison of $\bar{\alpha}$ with $\alpha(n)$ using optimal transport which forces us to deal with probability distributions. This is the reason which explains why *null distribution* does not depends on $n$.

We draw the reader's attention to the fact that the choice of the null distribution is left to the researcher, and nothing prevents considering other distributions as references against which one wishes to compare the empirical distributions $(\alpha_n)$.

Finally, in order to compare $\alpha(n)$ and $\bar{\alpha}$, we use the theory of optimal transport introduced above: given a distance-cost matrix $C = (C_{ij})$ that encodes the cost of moving mass from unit

$i$ to unit $j$ (a distance, a travel time, or any other cost), we define the heterogeneity index $D(n)$ for group $n$ as follows.

**Definition (OT Global Index)** The global heterogeneity index for the group $n$ is defined as the optimal transport distance from $\alpha(n)$ to $\bar{\alpha}$, that is

$$ D(n) = OT_C(\alpha(n), \bar{\alpha}) \quad (2) $$

and the global index $D$ as the weighted average,

$$ D = \sum_{n=1}^{N} p(n)D(n) $$

where

$$ p(n) = \frac{\sum_{i=1}^{I} A_i(n)}{\sum_{n'=1}^{N} \sum_{i=1}^{I} A_i(n')} $$

is the overall proportion of group $n$ across all groups.

Intuitively, $D(n)$ captures the spatial dissimilarity between the actual distribution of group $n$ and a fixed spatially homogeneous baseline, with respect to the cost $C$.

**Example 1** To illustrate the above definition and indices, we consider a simple example involving two areal units and two distinct groups. In that simple case, the distance-cost matrix $C$ will be 0 if $i = j$ and (for instance) 1 otherwise.

Assume the distribution of group members across the two units is as follows: in unit 1, there are 10 individuals from group 1 and 2 from group 2; in unit 2, there are 2 individuals from group 1 and 4 from group 2. In our notation:

$$ \begin{aligned} A_1(1) &= 10, A_2(1) = 2, \\ A_1(2) &= 2, A_2(2) = 4. \end{aligned} $$

The total number of individuals from group 1 is 12, and from group 2 is 6, giving global proportions

$$ \begin{aligned} p(1) &= \frac{12}{18} = \frac{2}{3}, \\ p(2) &= \frac{6}{18} = \frac{1}{3}. \end{aligned} $$
If distributions of both groups were spatially homogeneous (i.e., matched with $\bar{\alpha}$ in each unit), we would expect unit 1 and unit 2 to each reflect the same global proportions. This leads us to the following distributions of individuals reflecting the homogeneous situation and both leading after renormalization by their total number of individuals to $\bar{\alpha}$,

$$ \begin{aligned} \bar{A}_1(1) &= 8, \bar{A}_2(1) = 4, \\ \bar{A}_1(2) &= 4, \bar{A}_2(2) = 2. \end{aligned} $$

The computation of $D(1)$ and $D(2)$ consists in solving the optimal transport problem between

$$ \alpha_1 = \frac{5}{6}\delta_1 + \frac{1}{6}\delta_2, \alpha_2 = \frac{1}{3}\delta_1 + \frac{2}{3}\delta_2 $$

and

$$ \bar{\alpha} = \frac{2}{3}\delta_1 + \frac{1}{3}\delta_2 $$

which easily gives us

$$ D(1) = \frac{1}{6}, D(2) = \frac{1}{3} $$

and

$$ D = \frac{2}{9}. $$

These calculations should be put in perspective with those performed when computing the dissimilarity index for two distributions [15]. The difference lies in taking into account the cost of moving to balance the distributions, which is not considered in the dissimilarity index.

## 2.2 Several local indices

So far, we have defined the global index as the optimal value of an optimization problem that minimizes a global cost. Now, the optimal coupling itself, will enable us to define several local indices corresponding each to a local contribution to the global index, one non-negative and one signed. The first reflects the contribution of each unit to global indices $D(n)$, whereas the second provides an interpretation in terms of incoming and outgoing flux.

Let $P^*(1), \dots, P^*(N)$ be solutions of the optimal transport problems of the equation (2), then by definition for every $n$,

$$ D(n) = \sum_{1 \le i,j \le I} C_{ij} P_{ij}^*(n) $$

and the equation (2) can be rewritten as,

$$ D(n) = \sum_{i=1}^{I} \bar{a}_i \omega_i^{out}(n) $$

where

$$ \omega_i^{out}(n) = \frac{1}{\bar{a}_i} \sum_{j=1}^{I} C_{ij} P_{ij}^*(n) $$

is the local contribution of $i$ to the global index with respect to $n$.

We can thus also define

$$ \omega_i^{out} = \sum_{n=1}^{N} p(n) \omega_i^{out}(n) $$

which is the local contribution of $i$ to the global index, irrespective of $n$, such that

$$ D = \sum_{i=1}^{I} \bar{a}_i \omega_i^{out}. $$

Notice that we added an index "out" to our $\omega$ variables, as the flux $P_{ij}^*$ is here taken as the outgoing flux. We can similarly define $\omega^{in}$ from the incoming flux $P_{ji}^*$, which conserve the same summation properties,

$$ \begin{aligned} \omega_i^{in}(n) &= \frac{1}{\bar{a}_i} \sum_{j=1}^{I} C_{ji} P_{ji}^*(n) \\ \omega_i^{in} &= \sum_{n=1}^{N} p(n) \omega_i^{in}(n) \end{aligned} $$

### 2.2.1 Mean flux

We note that it would not make particular sense to choose between entering and exiting flux as heterogeneity can be expressed as both a lack or a surplus of a certain group $n$ at the unit $i$.

Thus we propose a local contribution that takes both entering and exiting flux into account
**Definition (OT Local Indices)** *Local heterogeneity indices are defined as follows*

$$ \omega_i = \frac{\omega_i^{in} + \omega_i^{out}}{2} \qquad (\text{Mean Flux}) $$

and if we want to specify the group,

$$ \omega_i(n) = \frac{\omega_i^{in}(n) + \omega_i^{out}(n)}{2}. $$

Finally we defined the signed index by

$$ \omega_i^{\pm}(n) = \frac{\omega_i^{out}(n) - \omega_i^{in}(n)}{2}. \quad (\text{Signed Index}) $$

Concerning this last index, we chose to define the local heterogeneity index as the average between the heterogeneity index resulting from exiting transportation and entering transportation at each locality, which are respectively signs of an over-representation and under-representation of the group studied.

This property allows us to define such a signed index $\omega_i^{\pm}(n)$ for each group for which the absolute value quantifies the situation of heterogeneity, and the sign represent if the specific group is under represented (negative sign) or over represented (positive sign).

Notice that this signed index is equal in absolute value to its counterpart $\bar{\omega}_i(n)$ if there is no locality $i$ such that both the exiting transport $\sum_j P_{ij}^*(n)$ and the entering transport $\sum_j P_{ji}^*(n)$ are non-zero. This property is notably true for a concave transport cost as laid out in 3.1.

# 3 Numerical simulations

The simulations are done with a python library implementing the indices we defined in this paper which we developed, and is available on Github :

github.com/jolatechno/ot-heterogeneity ; and on Pypi and can thus simply be installed by using the command :

pip install oterogeneity

This library uses the python library POT: Python Optimal Transport as a backend to solve the optimal transport problem.

## 3.1 Further remarks on the Euclidean cost

**Every optimal coupling leads to a local index.** While the global index $D(n)$ depends on $C$, local indices also depend on the specific solution $P^*(n)$ selected from the set of optimal couplings defining it. Indeed, we recall that since optimal transport is formulated as a linear programming problem (that is, linear objective subject to linear constraints), the uniqueness of the solution is generally not satisfied. This non-uniqueness arises notably when $C$ corresponds to the Euclidean distance on $\mathbb{R}^d$ since the cost is purely additive when three points are inline.

Therefore in such case, we must specify which solution among all we decided to consider when defining our local indices. Such a choice is far from neutral since this will lead to different local indices with the ability to detect different types of segregation as we will see later, studying specific examples.

**Book shifting.** To clarify the above statement, we will examine in detail a simple example where the units are aligned and the considered cost is the Euclidean one. This is an adaptation of the well-known book shifting problem in optimal transport, which consists in finding the best way to move to the right a bookshelf, depending on the cost of interest. Despite its simplicity, this example contains all the complexity of the main issues.

Let $\mathcal{X} = \{0, 1, 2, 3, 4\}$ be the ambient space and consider as two distributions $\alpha_1$ and $\alpha_2$ defined by

$$ \mathbf{a}_1 = \frac{1}{4}(1, 1, 1, 1, 0), \mathbf{a}_2 = \frac{1}{4}(0, 1, 1, 1, 1) $$

thus $\bar{\mathbf{a}}\alpha$ is given by

$$ \bar{\alpha} = \frac{1}{L}(1/2, 1, 1, 1, 1/2) $$

and consider the cost $C(x, y) = |x - y|$. Since all the units are line, the cost is purely additive and from any optimal coupling, one may create a new optimal coupling just by breaking down any displacement of mass from $i$ to $j$ into a displacement from $i$ to any halfway unit $i'$ and
a displacement from $i'$ to $j$ of the same amount of mass.

Focusing our discussion on the computation of $D(1)$, we may exhibit two particular solutions, respectively given by

$$ \mathbf{P}(1)^- = \begin{bmatrix} 1/2 & 0 & 0 & 0 & 1/2 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 \end{bmatrix} $$

and

$$ \mathbf{P}(1)^+ = \begin{bmatrix} 1/2 & 1/2 & 0 & 0 & 0 \\ 0 & 1/2 & 1/2 & 0 & 0 \\ 0 & 0 & 1/2 & 1/2 & 0 \\ 0 & 0 & 0 & 1/2 & 1/2 \\ 0 & 0 & 0 & 0 & 0 \end{bmatrix}. $$

On the one hand, $\mathbf{P}(1)^-$ moves only the mass from the leftmost unit directly to the rightmost unit, leaving all the rest in place. This coupling is actually the unique optimal coupling when the considered cost in concave with respect to the Euclidean distance and has the form $|x-y|^p$ with $p \in (0, 1)$. On the other hand, $\mathbf{P}(1)^+$ translates half of the mass and corresponds to the unique solution of the same optimal transport problem with a convex cost of the form $|x-y|^p$ with $p > 1$.

In other words, the concave solution leaves the common mass in place and performs large displacements for the remaining mass, whereas the convex solution has tendency to move more mass but over small distances.

## Convex and concave cost approximation

As discussed above, the choice of $C$ implies a topologization of the space: it tells us which units are close to each other and, more precisely, quantifies this proximity. Depending on the problem of interest, a particular choice of $C$ may be natural — for instance, the straight-line distance, the railway distance, or the travel time required to move from one locality.

In the optimal transport literature, one common class of cost functions consists of those that are functions of distance. Within this class, two particular groups are often distinguished: those defined as a concave power of

the distance and those defined as a convex power. The reason is that each of these two groups shares many common properties regarding the structure of the optimal couplings.

However, it should be noted that one is not required to choose a cost function that depends on an underlying geographical distance inherent to the data.

### Near-linear cost relative to straight-line distance
As mentioned above, solving the optimal transport problem may lead to several optimal couplings. We can break this multiplicity of solutions by associating to a transport between two points $i$ and $j$ a slightly non-linear cost

$$ C_{ij} = (d_{ij})^{1 \pm \epsilon} $$

with $d_{ij}$ the distance (either the geographical distance, or the travel distance or time) between the two points $i$ and $j$, and $\epsilon$ being a small non-negative constant. This little trick breaks the non-uniqueness of the optimal coupling and formally corresponds to a focus on a particular solution among all the optimal couplings. Indeed, a classical result in optimal transport ensures that for any strictly convex or concave cost, the uniqueness of the solution is satisfied [17].

We thus have the choice between plus or minus $\epsilon$, thus respectively a convex or concave cost. In this paper we argue for the use of a concave cost. Our first argument is that the real travel time is by nature concave; both across most of the mode of transportation as a 200km drive is typically less than 10 times longer than a 20km drive as the percentage of time driving over high-speed roads will be higher; and also over the real travel time as the proportion of people using a faster mode of transportation time (driving over waling, taking the train over driving and flying over other modes of transportation) will increase with the length of the distance traveled.

One other effect of concavity motivating our choice is that all things being equal, a concave cost will encourage long-range transportation
from center to center of segregated communities, whereas a convex cost encourages a higher amount of short ranges transport across and near the borders of segregated communities. To illustrate this point, we invite the reader to think on the classical example in optimal transport of book shifting: how do we move N books stored on a shelf to the right in order to minimize the total cost? If the cost to move one book to an initial position to a final one is a convex power of the distance, then the optimal way is a translation of every book to right, while in the concave case the only book which moves is the leftmost one which is displaced into the right of the rightmost one, every other books staying in place.

Although this choice doesn't affect the global segregation index we defined earlier in this paper, the effect on the local segregation index is that the concave cost highlights - i.e. results in a higher local segregation index - the center of the segregated communities, whereas the convex cost highlights the area near border between segregated communities. We believe that the most segregated area - and thus the one which should have the highest segregation index - inside a segregated community is the one at the center as it is the furthest away from other communities.

## 3.2 Analysis of canonical examples

**3 by 3 checkerboard** In figures 1.a-1.c we apply our index to a distribution of a 3 by 3 alternating pattern of zones fully populated by one population (green) or the other (red), with constant spacial density and without boundary conditions.

We see in figure 1.b that our index based on a concave cost is highest the further away from the border with another population, and falls to zero at the border. Note that the index is the highest near the edge of the space as these are the points the furthest away from the other population. This behaviour suggests that this index measures clustering in the sense of heterogeneity measures [9].

In figure 1.c we observe that our index based

on a convex cost is generally highest at the border between two zones of different populations, which would correspond to measuring exposure [9]. However it has some other less regular behaviours, including a near zero output at the crossing between two borders, and a near zero value at the diagonal of the space.

### Sensitivity to the granularity of the data

In figure 2.a we show the global index for the 3 by 3 checkerboard versus the number of number of data points present in each population zone (2 means each zone has a grid of 2 by 2 data points thus 4 data points). While the size and total population of the problem stays the same, the number and thus position of data points will have an impact on the distance traveled. We see that for 1 data point per zone the global index is higher than with more data points, but the convergence is fast as a grid of 2 by 2 data points per zone is less than 10% away to the final value with a grid of 21 by 21 data points, and a grid of 4 by 4 (thus an accumulation of about 25 to 1 compared to a grid of 21 by 21) is less than 2% away from the final value. This suggests that our index is not very sensitive to the spacial granularity of the data points when accumulation doesn't change the underlying spacial distribution.

**Sensitivity to the size of area of different population** Figure 2.b shows the evolution of the global index versus the number of zones in the checkerboard problem (2 means a 2 by 2 grid of alternating populations, 3 would represent the distribution shown in figure 1.a) with constant total size and population. We see that graphing this as a log-log graph our index follows a decreasing power-law, thus smaller zones of concentrated population leads to a lower index. This is in line with our index measuring clustering [9] as two cities composed of two different population is a higher level of clustering as two cities composed of building each composed only of one population in an alternating manner. Note that a purely local index like the Theil index (itself based on the KL divergence) would lead to a constant heterogeneity for all this situation as each unit is composed of purely
<figure><img src="image_2.png" /><figcaption>1.a Distribution of the two pop- 1.b Concave-cost local hetero- 1.c Convex-cost local heterogene-
ulations (red and green), with geneity index for the population ity index for the population dis-
constant population density and distribution shown in figure 1.a. tribution shown in figure 1.a.
without boundary conditions.</figcaption></figure>

<caption>Figure 1: 3 by 3 checkerboard canonical example.</caption>

one population independently of the size of the
units, i.e. they measure concentration rather
than clustering [9].

**Application to a noisy border** For figures 3.a-3.c we generated a problem with constant population density and two populations, but with a noisy border between the two populations.

We see in figure 3.b that our index based on
a concave cost is highest in area composed of a
singular population and the furthest away from
the nearest neighboring zone composed of a dif-
ferent population, and is zero at the border be-
tween these zone.

The convex cost index shown in figure 3.c on
the other end is highest at the border, but with
a varying intensity along the border as it is sen-
sitive to the depth at each specific point along
the border of the zones of different population
on each side of the border.

**Sensitivity to population density** Figures 4.a-4.f shows our index used to measure heterogeneity in a set of two different population densities with the same spatial distribution of the two populations.

Figure 4.d shows that our index based on a
concave cost is insensitive in this example to
the density of population as the distribution

of the index is the same between both cases,
and would be the same for a constant den-
sity. While we could imagine this being a good
thing for measuring across a geographical area
of variable density, this can be a good or a bad
thing depending on the nature of the hetero-
geneity we want to detect. Note however that
this property doesn't hold in general.

Finally, in figures 4.f and 4.e we see that the
index based on a convex cost is sensitive to pop-
ulation density.

3.3 Application to Electoral Results

We now describe a concrete application of our
method concerning the spatial analysis of elec-
toral results. Our dataset consists of the result
in Paris of the first round of the French presi-
dential election in which twelve candidates were
running.

In our model, each candidate corresponds to
a group *n*, with $1 \le n \le 12$. The country is
divided into *I* units, each corresponding to a
unique polling station, whose geographical co-
ordinates are denoted by $(x_i)$, for $1 \le i \le I$.
Using definitions introduced earlier, we denote
by $A_i^{(n)}$ the number of votes for candidate *n*
at polling station *i* and $a_i^{(n)}$ the proportion of
votes for candidate *n* at station *i* relative to
<figure><img src="image_3.png" /><figcaption>2.a Evolution of the global heterogeneity index versus the granularity of the distribution (size of the grid of data-point per spatial zone).</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>2.b Evolution of the global heterogeneity index versus the number of zones in the distribution. For example fig 1.a would be placed at marker 3 on the X-axis.</figcaption></figure>

the total number of votes received by that candidate in Paris and $α^{(n)}$ the resulting spatial distribution of votes for candidate $n$.

As for the global dissimilarity indices *D*, they are approximately 600 meters for E. Macron, and 1100 meters for both J-L Mélenchon and É. Zemmour (for context, the average radius of Paris is approximately 5 km).

We didn't opt to use a travel-time cost in the real-world analysis we show in this paper, as we didn't develop a weight-profile for transports mode depending on distance; and the computational cost of computing transport time between each locality in a set of tens of thousands of locality - here all voting bureau in metropolitan France - is very high, such that we didn't consider it interesting to explore in this paper.

**Distribution of votes** Figure 5.a-5.d displays the spatial distribution (as a proportion of votes) of the three leading candidates in Paris: E. Macron (35.5%), J-L Mélenchon (29.9%), and É. Zemmour (8.2%). We qualitatively observe a general opposition between the north east of Paris (20th and 19th arrondissement) which vote more for the left-wing candidate J-L Mélenchon and less for the president elect E. Macron and the far right candidate É. Zemmour, while the south west of Paris (mainly 16th arrondissement) has a higher proportion of vote for E. Macron, and represents a majority of the votes for É. Zemmour.

**Local heterogeneity** Figure 6.a shows the local heterogeneity index for all candidates. We can see the two areas of particular votes in the north east and south west that we saw in figures 5.a-5.d.

Figure 6.b represents the signed heterogeneity index for E. Macron, with hashing being preset where the index is negative, and the color representing the absolute value of the index. We also observe the same dynamic of over-representation of votes for E. Macron in the south west and under-representation in the North East.
<figure><img src="image_5.png" /><figcaption>3.a Distribution of the two populations (red and green), geneity index for the population density and without boundary conditions. The two regions are separated by a random border generated using Perlin noise.

3.b Concave-cost local heterogeneity index for the population distribution shown in figure 3.a.

3.c Convex-cost local heterogeneity index for the population distribution shown in figure 3.a.</figcaption></figure>

Figure 3: Synthetic example based on a noisy border generated with Perlin noise.

<figure><img src="image_6.png" /><figcaption>4.a Distribution of the two populations (red and green), without associated with the distribution boundary conditions. The density is shown in figures 4.b and 4.c.

4.b Case A for population density

4.c Case B for population density

4.a of population shown in figure 4.a.</figcaption></figure>
<figure><img src="image_7.png" /><figcaption>4.d Concave-cost local heterogeneity index for both density case A and B shown in figures 4.b in figure 4.c.</figcaption></figure>

<caption>4.f Convex-cost local heterogeneity index for density case B shown in figure 4.c.</caption>

Figure 4: Synthetic example showing the impact of the population density on the local heterogeneity index.

<figure><img src="image_8.png" /><figcaption>5.a Distributions of the proportion of votes for E. Macron.</figcaption></figure>

<figure><img src="image_9.png" /><figcaption>5.b Distributions of the proportion of votes for J-L Mélenchon.</figcaption></figure>

<figure><img src="image_10.png" /><figcaption>5.c Distributions of the proportion of votes for É. Zemmour.</figcaption></figure>

<figure><img src="image_11.png" /><figcaption>5.d Total proportion of votes for each candidates across Paris.</figcaption></figure>

Figure 5: Distribution of votes for the 2022 presidential election in Paris.
<figure><img src="image_12.png" /><figcaption>6.a Local concave-cost heterogeneity index in Paris for all candidates, measured in meters.</figcaption></figure>

<figure><img src="image_13.png" /><figcaption>6.b Local signed concave-cost heterogeneity index in Paris for E. Macron, measured in meters. Hashed zone represent the regions where the local heterogeneity index is negative, with the absolute value of the index being represented by the color.</figcaption></figure>

<figure><img src="image_14.png" /><figcaption>7.a Comparison of our concave-cost and convex-cost heterogeneity indices in Paris, with blue and red points corresponding to the regions highlighted in the map shown in figure 7.b.</figcaption></figure>

<figure><img src="image_15.png" /><figcaption>7.b Map of the comparison shown in figure 7.a, with regions highlighted in blue being the 10% of lowest ratio of the convex-cost index to the concave-cost index, and region highlighted in blue the 10% of highest ratio of the convex-cost index to the concave-cost index.</figcaption></figure>

## 3.4 Comparison to other index

**Comparison between concave-cost and convex-cost** In figure 7.a we plot the relationship between the concave-cost index and convex-cost index. We can first see that one cost can be high with the other near zero, indicating that these two indices measure different phenomenon.

In 7.b we highlight the zones where the concave-cost index is highest in comparison to the convex-cost index, and the opposite. We see that the concave-cost index is highest compared to the convex-cost index in the regions
<figure><img src="image_16.png" /><figcaption>8.a Comparison of our concave-cost heterogeneity indices and the KL-divergence in Paris, with blue and red points corresponding to the regions highlighted in the map shown in figure 8.b. Here the KL-divergence means the KL-divergence between the vector of proportion of votes for each candidates locally to the vector of proportion of votes in the whole of Paris as shown in figure 5.d.</figcaption></figure>

we observed as being a clustering of particular votes: the north east and south west of Paris. On the other hand the convex-cost index is highest near the border between the two zones of particular votes.

**Comparison between the concave-cost index and the KL-divergence** Like in figure 7.a, figure 8.a shows the relationship between the concave-cost index and local KL-divergence to the global result (i.e. average across Paris). We can see that there is a strong positive correlation between these two indices, meaning that our concave-cost index is high when the distribution of votes locally is different from the global average.

Note that this is a property of the distribution found in Paris, as we saw in figure 2.b that our concave-cost index is sensitive to the size of zones of concentration (i.e. clustering), while the KL-divergence is not. We can theorize that this strong correlation in figure 8.b is in part due to the fact that we study only a single city with mainly two separated zones and thus a singular situation of heterogeneity, and not a variety of different types of heterogeneity that our index would discriminate while the KL-divergence wouldn't.

<figure><img src="image_17.png" /><figcaption>8.b Map of the comparison shown in figure 8.a, with regions highlighted in blue being the 10% of lowest ratio of the KL-divergence to the concave-cost index, and region highlighted in blue the 10% of highest ratio of the KL-divergence to the concave-cost index.</figcaption></figure>

In 8.b we highlight the zones where the concave-cost index is highest in comparison to the KL-divergence, and the opposite. While the pattern is weaker than in figure 7.b, we see that the concave-cost index is highest only in zones of particular vote (north east and south west) - but isn't high in all of them -, and the KL-divergence is highest only in zone along or near the border between zones of particular vote - but isn't high all along the border, like the convex-cost index is.

Note that the south west - which is highlighted as the having the highest heterogeneity by our concave-cost index - isn't highlighted here because it is also particularly heterogeneous according to the KL-divergence and thus lays on the top-right of figure 8.a.

# 4 Conclusion

In this article, we have proposed a framework consisting of one global index leading to two local indices. All these indices are designed to address the spatiality problem. We have seen that without modifying the global index we may modify slightly the cost to produce new different local indices that measure empirically different aspects of the situation: clustering for the concave modification and exposure for the convex one. This framework has been imple-
mented in the context of electoral results and has been compared to the KL-divergence index.

This work is intended to be a first prospecting about the use of the coupling solution of optimal transport in the field of heterogeneity or segregation indices and now we would like to describe briefly the future works that can be made:

1. Vary the null distribution we compare the real distribution to : instead of seeing the null distribution as the spatially homogeneous distribution, we could define it in many ways, for example by taking into account other variable and using as a null distribution the distribution that would be predicted from these other variables using a statistical regression.

2. Even though our main focus was to compare several spatial distributions, the global index $D(n)$ may be use to characterize a single distribution by comparing it with what we consider to be a benchmark. For instance, in order to characterize medical desert we may compare the distribution of physicians with a distribution proportional to the population or even depending of the demographic distribution of the areal unit we choose to consider.

3. We decided to not include an additional index in the core of the text, which is a vector index, and defined as the mean direction of the origin of heterogeneity for the group $n$ at locality $i$, that is

$$ \vec{\omega}_i(n) = \frac{1}{\bar{a}_i} \sum_{j=1}^{I} \vec{u}_{ij} \frac{C_{ij} \mathbf{P}_{ij}^*(n) + C_{ji} \mathbf{P}_{ji}^*(n)}{2} $$

with $\vec{u}_{ij} = (x_j - x_i)/|x_j - x - i|$ being the unitary vector directed from locality $i$ to locality $j$.

This index can naturally be compared to its scalar counterpart $\omega_i(n)$ which leads to defining

$$ \tilde{\omega}_i(n) = \frac{\vec{\omega}_i(n)}{\omega_i(n)} $$

which represents the relative directionality of our local heterogeneity index : If this index is zero (independently of the value of $\omega_i(n)$), then the transport done at location $i$ is not skewed one way, whereas if it points with a strength one to one direction then all of the transport is done to and from this direction.

4. Develop a mathematical framework for selecting a particular solution when the ground cost is Euclidean and so synthesize the literature on optimal transport about it. For instance we know that with such a cost, in absolute continuity case, the optimal planning of the convex cost is the same that the Monge's solution of the Euclidean cost (see [19], chapter 2). However, what do we know when the distributions are discrete? Furthermore, research will be for instance to see the link between the vector index $\vec{\omega}_i(n)$ and the vector-field formulation in Optimal Transport such as the Beckmann's formulation [17], [16]) which states that in the Euclidean cost case, the optimal transport problem is equivalent to the minimization of the total variation of a vector field subject to a Kirchhoff's law.

5. The definition above extend naturally to the general setting of probability measures on $\mathbb{R}^d$. This kind of generalization may be seen as a response to the problem of non continuity of the number of optimal couplings with respect to the ground space $\mathbb{R}^d$ in the discrete case: if we consider for instance in $\mathbb{R}^2$ the following optimal transport problem between two coupled of Dirac measures with the Euclidean distance as ground cost $C(x, y) = \|x - y\|_2$,

$$ \mu = \frac{1}{2} \delta_{(-1,0)} + \frac{1}{2} \delta_{(0,t)}, $$

$$ \nu = \frac{1}{2} \delta_{(1,0)} + \frac{1}{2} \delta_{(0,t)}, $$

the cardinal of the set of optimal couplings is given by $1$ if $t \neq 0$ $\infty$ if $t = 0$.

As a consequence our local indices may be strongly dependent of the centroid of the
areal unit we consider. Something we may
want to avoid.

**Acknowledgements:** Xavier Bacon acknowledges funding from the SAFEPAW project, supported by the French national research agency through the France 2030 program ANR-22-PESN-0005. Joseph Touzet acknowledges funding from ENS Paris-Saclay via the CDSN PhD Grants program.

References

[1] William Edward Burghardt Du Bois and Isabel Eaton. *The Philadelphia negro: A social study*, volume 14. Published for the University, 1899.

[2] Flávia F Feitosa, Gilberto Camara, Antônio Miguel Vieira Monteiro, Thomas Koschitzki, and Marcelino PS Silva. Global and local spatial indices of urban segregation. *International Journal of Graphical Information Science*, 21(3):299–323, 2007.

[3] Mauro Ferrante, Giovanni Luca Lo Magno, Stefano De Cantis, and Geoffrey JD Hewings. Measuring spatial concentration: A transportation problem approach. *Papers in Regional Science*, 99(3):663–682, 2020.

[4] Alfred Galichon. *Optimal transport methods in economics*. Princeton University Press, 2018.

[5] Laetitia Gauvin and Julien Randon-Furling. Segregation in cities. In *Compendium of Urban Complexity*, pages 137–155. Springer, 2025.

[6] John F Jakubs. A distance-based segregation index. *Socio-economic planning sciences*, 15(3):129–136, 1981.

[7] Leonid V Kantorovich. On the translocation of masses. *Journal of mathematical sciences*, 133(4), 2006.

[8] Giovanni L Lo Magno, Mauro Ferrante, and Stefano De Cantis. A new index for

measuring seasonality: A transportation
cost approach. *Mathematical Social Sci-
ences*, 88:55–65, 2017.

[9] Douglas S. Massey and Nancy A. Denton. The dimensions of residential segregation*. *Social Forces*, 67(2):281–315, 12 1988.

[10] Gaspard Monge. Mémoire sur la théorie des déblais et des remblais. *Mem. Math. Phys. Acad. Royale Sci.*, pages 666-704, 1781.

[11] Barrie S Morgan. A distance-decay based interaction index to measure residential segregation. *Area*, pages 211–217, 1983.

[12] Vinicius Netto, Kimon Krenz, Maria Fiszon, Otavio Peres, and Desiree Rosalino. Decoding segregation: The topological landscape of segregation forms and a bottom-up ontology. 2025.

[13] Robert E Park and Ernest W Burgess. *The city*. University of Chicago press, 2019.

[14] Gabriel Peyré, Marco Cuturi, et al. Computational optimal transport: With applications to data science. *Foundations and Trends in Machine Learning*, 11(5-6):355-607, 2019.

[15] Sean F Reardon and Glenn Firebaugh. Measures of multigroup segregation. *Sociological methodology*, 32(1):33–67, 2002.

[16] Sawyer Robertson, Zhengchao Wan, and Alexander Cloninger. All you need is resistance: On the equivalence of effective resistance and certain optimal transport problems on graphs. arXiv preprint arXiv:2404.15261, 2024.

[17] Filippo Santambrogio. Optimal transport for applied mathematicians. *Birkhäuser, NY*, 55(58-63):94, 2015.

[18] Mihai Tivadar. Oasisr: An r package to bring some order to the world of segregation measurement. *Journal of Statistical Software*, 89:1–39, 2019.
[19] Cédric Villani. *Topics in optimal transportation*, volume 58. American Mathematical Soc., 2021.

[20] Jing Yao, David WS Wong, Nick Bailey, and Jonathan Minton. Spatial segregation measures: A methodological review. *Ti-jdschrift voor economische en sociale ge-ografie*, 110(3):235-250, 2019.