title: How to apply chi-square distance on categorical dataset?
body: <p>I want to apply chi-square distance on a categorical dataset (219 x 55).
  As I understand, categorical data must be encoded first before applying the chi-square formula (<a href="http://www.econ.upf.edu/%7Emichael/stanford/maeb4.pdf" rel="nofollow noreferrer">reference</a>, P.10).
  The formula for chi-square distance is as follow:</p>
     <img src="https://latex.codecogs.com/svg.image?%5Cchi%5E2(l,k)&space;=&space;%5Csqrt%7B%5Csum_j&space;%5Cfrac1%7Bx_%7B&plus;j%7D%7D%5Cleft(%5Cfrac%7Bx_%7Blj%7D%7D%7Bx_%7Bl&plus;%7D%7D-%5Cfrac%7Bx_%7Bkj%7D%7D%7Bx_%7Bk&plus;%7D%7D&space;%5Cright)%5E2&space;%7D" title="\chi^2(l,k) = \sqrt{\sum_j \frac1{x_{+j}}\left(\frac{x_{lj}}{x_{l+}}-\frac{x_{kj}}{x_{k+}} \right)^2 }" />
  <p>Where the row totals is denoted<br />
  <img src="https://latex.codecogs.com/svg.image?x_%7B&plus;j%7D=%5Csum_i&space;x_%7Bij%7D" title="x_{+j}=\sum_i x_{ij}" /><br />
  and the column totals are<br />
  <img src="https://latex.codecogs.com/svg.image?x_%7Bi&plus;%7D=%5Csum_j&space;x_%7Bij%7D" title="x_{i+}=\sum_j x_{ij}" />.</p>
  <p>I am struggling to understand what sort of output I will be getting from applying this formula to my dataset. Is it a matrix of distances between rows that symmetrical across the diagonal (similar to the one found in the reference)?</p>
  <p>Or is it a matrix with the same proportion of my dataset but each value is substituted with the distance?</p>
  <p>Finally, is there a method for chi-square distance in python?</p>