Suppose one has $n > 2$ points in $R^2$, and one wants to measure "how linear" they are. I want a metric such that (a) if all the points are in fact on the same line, the metric gives 1, (b) if all the points are equally spaced on a circle, the metric gives 0. What metrics are there that satisfy these criteria?
-
$\begingroup$ The question is too broad, as there are infinitely many such "metrics". The question is also unclear: (i) is $n$ fixed? (ii) the term "metric", which normally stands for a function of two arguments, is not used appropriately. $\endgroup$– Iosif PinelisCommented Nov 11 at 13:48
-
$\begingroup$ Do you have a response to the answer below? $\endgroup$– Iosif PinelisCommented Nov 12 at 21:52
-
$\begingroup$ Thanks very much Iosif - I will check that now. $\endgroup$– Michael Mc GettrickCommented Nov 15 at 15:49
-
$\begingroup$ Have you checked it? $\endgroup$– Iosif PinelisCommented Nov 24 at 0:59
1 Answer
$\newcommand\R{\Bbb R}\newcommand\la{\lambda}$One good "metric" is as follows. Let $S$ be your finite set of $n\ge2$ distinct points in $\R^2$. Let $C(S)$ be the covariance matrix of the uniform probability distribution $U(S)$ over $S$: $$C(S)=\frac1n\sum_{s\in S}(s-\bar s)(s-\bar s)^\top,$$ where $\bar s:=\frac1n\sum_{s\in S}s$ is the mean of the distribution $U(S)$; as usual, we identify $\R^2$ with the set of all $2\times1$ real column matrices.
Then
- if all the points in $S$ lie on the same straight line, then the eigenvalues of $C(S)$ are $\la$ and $0$ for some real $\la>0$;
- if all the points in $S$ are equally spaced on a circle, then the eigenvalues of $C(S)$ are $\la$ and $\la$ for some real $\la>0$.
So, a good "metric" of linearity of $S$ is $$L(S)=1-\frac{\la_2(S)}{\la_1(S)},$$ where $\la_1(S)\ge\la_2(S)\ge0$ are the eigenvalues of the (positive-semidefinite nonzero) covariance matrix $C(S)$. Indeed, then $L(S)=1$ if (and only if) all the points in $S$ lie on the same straight line, and $L(S)=0$ if all the points in $S$ are equally spaced on a circle.