You would calculate the eigenvectors of the 2x2 matrix, which can be done with a few simple formulas, so itβs not so difficult. In pseudo code:
You could even do this by adding up only a few of the points to get an estimate if you expect the subset of points you have chosen to represent the complete set.
Change I think that x and y should be converted to a zero-average, that is, subtract the average from all x, y first (eed3si9n).
source share