Rudimentary factor analysis in js