MCPcopy Create free account
hub / github.com/creatale/node-dv / vector_fit

Method vector_fit

deps/tesseract/ccstruct/linlsq.cpp:252–259  ·  view source on GitHub ↗

This is equivalent to returning the Principal Component in PCA, or the eigenvector corresponding to the largest eigenvalue in the covariance matrix. However, atan2 is much simpler! The one reference I found that uses this formula is http://web.mit.edu/18.06/www/Essays/tlsfit.pdf but that is still a much more complex derivation. It seems Pearson had already found this simple solution in 1901. http

Source from the content-addressed store, hash-verified

250// found this simple solution in 1901.
251// http://books.google.com/books?id=WXwvAQAAIAAJ&pg=PA559
252FCOORD LLSQ::vector_fit() const {
253 double x_var = x_variance();
254 double y_var = y_variance();
255 double covar = covariance();
256 double theta = 0.5 * atan2(2.0 * covar, x_var - y_var);
257 FCOORD result(cos(theta), sin(theta));
258 return result;
259}

Callers 1

MeanDirectionVectorFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected