# [Numpy-discussion] distance matrix and (weighted) p-norm

Emanuele Olivetti emanuele@relativita....
Mon Sep 8 11:04:32 CDT 2008

Damian Eads wrote:
> Emanuele Olivetti wrote:
>> ...
>> [*] : ||x - x'||_w = (\sum_{i=1...N} (w_i*|x_i - x'_i|)**p)**(1/p)
>
> This feature could be implemented easily. However, I must admit I'm not
> very familiar with weighted p-norms.  What is the reason for raising w
> to the p instead of w_i*(|x_i-x'_i|)**p?
>

I believe that it is just a choice, that should be clearly expressed
since the two formulations lead to different results. I think the
expression I wrote is more convenient, since it gives what it is
expected even in limit cases. 2 examples:
1) if |x-x'|=N.ones(n) , then ||x-x'||_w,p = ||w||_p
||x-x'||_w,p = (\sum(w_i))**(1/p)
breaking this symmetry
2) when p goes to inifinity in my case:
||x-x'||_w,inf = max(w_i*|x_i-x'_i|_{i=1,...,n})
||x-x'||_w,inf = max(|x_i-x'_i|_{i=1,...,n}) = ||x-x'||_1,inf

But I welcome any comment on this topic!

Emanuele