Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



19 Commits

Repository files navigation

Cumulative Distribution Transform

Cumulative distribution transform (CDT) as described in:

(1) Park SR, Kolouri S, Kundu S, Rohde GK. The cumulative distribution transform and linear pattern classification. Applied and Computational Harmonic Analysis. 2017 Feb 22.

is a nonlinear and invertible transformation for nonnegative one-dimensional signals that guarantees certain linear separation theorems. CDT rises from the rich mathematical foundations of optimal mass transportation, and therefore has a unique geometric interpretation. Unlike the current data extensive nonlinear models, including deep neural networks and their variations, CDT provides a well-defined invertible nonlinear transformation that could be used alongside linear modeling techniques, including principal component analysis, linear discriminant analysis, and support vector machines (SVM), and does not require extensive training data.

The corresponding iPython Notebook file for this post could be find here. The demo is tested with:

  1. numpy '1.13.1'
  2. sklearn '0.18.1'
  3. scipy '0.19.1'

Here we first walk you through the formulation of CDT and then demonstrate its application on various demos.


Consider two nonnegative one-dimensional signals and defined on . Without the loss of generality assume that these signals are normalized so that they could be treated as probability density functions (PDFs). Considering to be a pre-determined 'template'/'reference' PDF, and following the definition of the optimal mass transportation for one-dimensional distributions, one can define the optimal transport map, using,

which uniquely associates to the given density .

Forward Transform

We use this relationship to define the ** Cumulative Distribution Transform (CDT)** of (denoted as ), with respect to the reference :

For one-dimensional PDFs the transport map is uniquely defined, and can be calculated from:

where and are the corresponding cumulative distribution functions (CDFs) for and , that is: , . For continuous positive PDFs and , is a continuous and monotonically increasing function. If is differentiable, we can rewrite the above equation as:

Inverse Transform

The Inverse-CDT of is defined as:

where refers to the inverse of (i.e. ), and where . The equation above holds for points where and are differentiable. By the construction above, will be differentiable except for points where and are discontinuous. Now we are ready to delve into some exciting applications of CDT.

CDT Demo

Throughout the experiments in this tutorial we assume that: 1) , and 2) the template PDF is the uniform distribution on . Lets start by showing the nonlinear nature of CDT.


Let and be two one-dimensional Gaussian distributions, where:

and let denotes the corresponding CDTs. The signals and their CDT could for instance be calculated from the code below:

import numpy as np
import transportBasedTransforms.cdt as CDT
#Define the template (Reference) PDF
I0= (1.0/N)*np.ones(N)
# Define the signals I_i and calculate their CDT
mu=np.array([25,200]) #Means
for i in range(2):

which results in,

<img src="" align=middle width=11.832645pt height=22.38192pt/>s and their corresponding CDT

Now to demonstrate the nonlinear nature of CDT, we choose the simplest linear operator, which is averaging the two signals. We average the signals in the signal space, , and in the CDT space, , and compare the results below.


which results in,

Averaging in the signal domain versus in the CDT domain

It can be clearly seen that CDT provides a nonlinear averaging for these signals. Note that we don't have a specific model for Gaussians and while CDT is unaware of the parametric formulation of the signals it can still provide a meaningful average. Next we will discuss the linear separability characteristic of CDT.

Linear separability

Park et al. (1) showed that CDT can turn certain not linearly separable classes of one-dimensional signals into linearly separable ones. Here we run a toy example to demonstrate this characteristic. We start by defining three classes of signals, where Class , for , consists of translated versions of a -modal Gaussian distribution. Here we generate these signal classes and their corresponding CDTs.

K=3 # Number of classes
L=500 # Number of datapoints per class  
for k in range(K):
    for i,mu in enumerate(np.linspace(50,200,L)):
        for j in range(k+1):

This leads to the following signals:

Sample signals from the three classes. CDT of the sample signals from the three classes.

Next we run a simple linear classification on these signals in the original space and in the CDT space.

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
lda=LinearDiscriminantAnalysis(n_components=2) #Get the classifier object
X=np.reshape(I,(K*L,N))      #Combine the signals into a features vector X
Xhat=np.reshape(Ihat,(K*L,N))     #Combine the transformed signals into a features vector Xhat
label=np.concatenate((np.zeros(L,),np.ones(L,),-1*np.ones(L,))) # Define the labels as -1,0,1 for the three classes
for i in range(2):

Below we visualize the two-dimensional discriminant subspace calculated by the linear discriminant analysis (LDA).

Visualization of the LDA subspace calculated from the original space and the CDT space.

It can be clearly seen that while the classes are not linearly separable in the original space (Note the one-dimensional nonlinear manifold structure of each class), the CDT representations of the signals is linearly separable.


Cumulative Distribution Transform






No releases published


No packages published