I have to use Hellinger distance to compare arrays that are not of the same length. Is there a way to do it correctly? Put zero in the missing fields of the shorter array doesn't sound that good to me but maybe I'm wrong.

More info on my data:

Most array dimensions are (1,58), but a some others are (1,28);

Arrays contain numbers from 1 to 3;


Array1=[1 1 3 2 3];

Array2=[2 3 1 1];

One possible solution: newArray2=[2 3 1 1 0];

Is possible to use Hellinger Distance ? is there any other distance function that could solve my problem ?

I'm using Helliger in a K-means because it's what the author of a paper I'm reading uses. So i would like to solve this issue using hellinger.


New contributor
Giacomo fava is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

What are you trying to do?

Don't blindly for together functions without thinking about the underlying math!

Hellinger distance is usually applied to histograms, and your before don't look like histograms. So something is wrong I'm your approach... Go back to the drawing board, not to the code.

P.S. k-means will also need vectors of the same length, and doesn't minimize Hellinger, I'd assume...

Your Answer

Giacomo fava is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.