# How to find the most similar profiles ?

Let's start with an example:

I would like to know what alternative for euclidean distance could be use to distinguish if orange or blue plot is "closer" to red one. In which situations I should apply euclidean distance and when Bayesian approach can be used ?

• I posted a proposal for a notion of distance between two curves (specifically, two probability distributions). I don't fully understand what you mean by the Euclidean distance (which only makes sense in finite-dimensional space) or what Bayesian statistics have to do with distances between curves - maybe you could elaborate? – Stephan Kolassa Feb 8 '17 at 12:12
• I analyze the expression of genes from specific group. We are looking for a homolog of our specific gene and we know that expression pattern across time (after specific induction) has to be similar to our gene. So, we plot an expression pattern of the gene of interest and we take a group of possible candidates, plot them and calculate a euc distance between our gene of interest and candidates. We take the one which has the smallest distance. I am quite sure that's not a best method... – Rechlay Feb 8 '17 at 12:26
• You could look into correspondence analysis – kjetil b halvorsen Feb 28 '17 at 11:41
• This seems to be as much a question of biology as a question of statistics. The question is: what measure of similarity do we expect gene homology to maximize. For example, for all I know we might expect that the shape will be similar, but the overall amount of expression could differ a lot between trials/organisms/genes/whatever. So you tell me: what type of similarity do you expect the biological mechanism to produce? Whatever your answer is, measure that! – Jacob Socolar Mar 2 '17 at 6:57

## 3 Answers

If you look for same shapes (meaning you don't care about shifting or amplitude scaling) then you can preform Pearson correlation and take the maximum of the shifts. Eventualy it comes down to this:

$similiarity = max_{\tau} |\frac{\int_{-\infty}^{\infty}x(t)y(t+\tau) dt}{||x||\cdot||y||}|$

I don't really understand what you meant in your comment since my biology knowledge is bad, but it sounds like you want the shape (but again, as said above, you should ask yourself what is "similiar")

If your curves are in fact probability densities (i.e., integrate to 1), or can meaningfully be scaled to be so, you could look at the Earth mover distance, AKA the Wasserstein metric. We have a couple of posts on this. In R, you can take a look at the emdist package.

• The data is normalized to 1. Explanation of the approach you can find in other comment. – Rechlay Feb 8 '17 at 12:27

Well, you could try out the Minkowski distance (which can be interpreted as the generalisation of the euclid distance). It is defined as: $$\textrm{Minkowski}(X, Y, \lambda)= \left(\sum_{i=1}^n |x_i-y_i|^\lambda\right)^{\frac{1}{\lambda}}$$

Try to vary $\lambda \in \mathbb{R}^{+}$, but pay attention that $\lambda < 1$ violates the triangle inequality and thus, the resulting function is not a true distance function anymore.

From my own experience, I've observed in many situations a peak in $\lambda =1$ which, when plugged into to above formula, results in the Manhatten distance.