1
$\begingroup$

I have a dataset of vectors and need to find the sum of squares or variance based on the euclidean distance between the vectors.

I can do this by finding the "average" vector (by calculating the average components of the vectors) and then summing up the squared euclidean distance between each vector and the average vector.

Is there a way to do this on the "fly" without calculating the average vector? I am familiar with the short cut method for finding the variance of a one-dimensional datasets and would like to find something similar for vectors.

Any help is greatly appreciated.

$\endgroup$
3

1 Answer 1

1
$\begingroup$

This wasn't really meant to be a stats question - more of a computational geometry question.

I think I found a way of doing this (at least for the euclidean distance measure).

First sum up each component for all the vectors. Then sum up the squared values for the components of all the vectors.

Now we have two new vectors: A "sum" vector containing the sum of each component and a "sumOFsquares" vector containing the sum of the squares of each components.

Assume n is the number of vectors in the dataset.

Then calculate sumOFsqaures - sum^2/n. Subtract the corresponding elements of sum from sumOFsquares) which will give a new vector.

Then sum up the components of this new vector. I tried this on a couple of examples and it seemed to give the Sum of Squares I was looking for.

I would be interested in finding a way to do this for other distance measures.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .