The question of the best approximating line to a set of points in Euclidean n-space (a "point cloud") is interesting. This can be thought of as a side-effect of applying the statistical method called analysis of variance to a set of points P = {p_k in R^n | 1 <= k <= r}. Think of r as being large. The general method works like this: 1. Approximate the point cloud by the normal density d : R^n —> R on R^n having the same mean mu in R^n as the sample mean and the same covariance matrix Sigma in Mat(n x n; R) as the sample covariance matrix. Sigma can be any symmetric positive semi-definite matrix. To avoid degenerate cases: Assume Sigma is actually *positive definite*. Then d is defined by d(x) = (1/K) * exp(-(1/2)<x, Sigma(x)>) where K = Integral_{R^n} exp(-(1/2)<x, Sigma(x)>) dvol, so that the integral of d(x) over R^n comes out to unity. 2. Now find the eigenvalues and eigenvectors of Sigma. The eigenvalues must all be positive reals, and the eigenvectors are mutually perpendicular. Assume they are ordered by size of eigenvalue: L_1 >= L_2 >= ... >= L_n > 0 with v_k the eigenvector corresponding to eigenvalue L_k. 3. Finally in a least-squares sense, the k-dimensional affine subspace of R^n A^k(P) = mu + <v_1, v_2, ..., v_k> that is the mean mu plus the span of the first k eigenvectors (call it A^k(P)) is "the closest approximating k-dimensional subspace" to the original set P of points, for any k in the range 1 <= k <= n. —Dan