jekyll / classifier-reborn

A general classifier module to allow Bayesian and other types of classifications. A fork of cardmagic/classifier.
https://jekyll.github.io/classifier-reborn/
GNU Lesser General Public License v2.1
551 stars 109 forks source link

improve numerical stability of vector.rb #209

Open alshedivat opened 4 months ago

alshedivat commented 4 months ago

when qrot[r, r] is close to 0, ruby might represent it with a small negative value (e.g., -2.8475347e-16), which results in error when passed to Math.sqrt. adding a small epsilon constant to qrot[r, r] inside Math.sqrt solves the issue.