Calculate similarity between assortment of grocery shopping basket I am trying to measure distances between basket assortments in a grocery shopping.
I have all information that who buys what in every shopping by online and offline.
I want to see the pattern of the assortments in baskets and compare between online shopping and offline shopping. 

So, for a certain customer, I am trying to measure how similar two shopped baskets are by calculating distance or something like that. 
I may be able to use several characteristics such as category, characteristics of products or something like that. 

Is there any way of calculating distance between this kind of groups (assortment of basket) ?
 A: Jaccard Index is often used to calculate similarity of such sample sets.
Let's assume there are 4 products $P_1,P_2,P_3,P_4$ that can be bought offline or online.
So if $S_{off} = [1,0,1,1]$ and $S_{on} = [1,0,0,1]$
Jaccard similarity = $\frac{S_{off}\cap S_{on}}{S_{off} \cup S_{on}} = \frac{2}{4} $
A: If you have the data in the form of a large table (well, matrix) with one row for each customer (or, maybe, each "basket") and one column for each product, and each matrix entry is maybe number of items bought or simply money.  Then, one possible and natural method of analysis will be correspondence analysis (mostly used for contingency tables, but nothing in the mathematics depends on data being counts).  Correspondence analysis uses implicitly what is called "chisquare distance", so that could be a natural distance measure between baskets (rows). 
If $E=\{E_{ij}\}$ is matrix above, we define for each row its profile 
$f_{ij} =  \frac{E_{ij}}{E_{i\cdot}}$. Note that $f_{i\cdot}=1$, here $\cdot$ means that index is summed out. The distance function (chisquared distance) between basket $i$ and basket $i'$ is then
$$
d^2(i,i') = \sum_j \frac{1}{E_{\cdot j}}\left\{f_{ij}-f_{i' j} \right\}^2.
$$
