(I can easily make the fix and add a test, but is the right thing to return 0, or instead proceed in the method with the value -sqrt(-llr) when llr is negative?)
On Thu, Apr 29, 2010 at 12:44 PM, Shashikant Kore <shashik...@gmail.com> wrote: > Root LLR calculation has a minor bug. When LLR score is negative, > square root is undefined. You can see the result for the following to > be NaN. > > org.apache.mahout.math.stats.LogLikelihood.rootLogLikelihoodRatio(6, > 7567, 1924, 2426487) > > A minor fix would be to return zero if LLR is less than zero as follows. > > public static double rootLogLikelihoodRatio(int k11, int k12, int k21, > int k22) { > double llr = logLikelihoodRatio(k11, k12, k21, k22); > if (llr < 0) > return 0; > return Math.signum(((double) k11 / (k11+k12)) - ((double) k21 / > (k21+k22))) * Math.sqrt(llr); > } > > --shashi >