Skip to content

Commit

Permalink
Improved names for arguments of Multi-normal. No functional changes.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/mahout/trunk@1409688 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
tdunning committed Nov 15, 2012
1 parent df130cb commit a2375a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ public static double logLikelihoodRatio(long k11, long k12, long k21, long k22)
* @return The root log-likelihood ratio
*
* <p/>
* See discussion of raw vs. root LLR at
* http://www.lucidimagination.com/search/document/6dc8709e65a7ced1/llr_scoring_question
* There is some more discussion here:
* http://mail-archives.apache.org/mod_mbox/mahout-user/201001.mbox/%[email protected]%3E
*
* And see the response to Wataru's comment here:
* http://tdunning.blogspot.com/2008/03/surprise-and-coincidence.html
*/
public static double rootLogLikelihoodRatio(long k11, long k12, long k21, long k22) {
double llr = logLikelihoodRatio(k11, k12, k21, k22);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,25 @@ public void testLogLikelihood() throws Exception {
}

@Test
public void testRootLogLikelihood() throws Exception {
public void testRootLogLikelihood() {
// positive where k11 is bigger than expected.
assertTrue(LogLikelihood.rootLogLikelihoodRatio(904, 21060, 1144, 283012) > 0.0);

// negative because k11 is lower than expected
assertTrue(LogLikelihood.rootLogLikelihoodRatio(36, 21928, 60280, 623876) < 0.0);

assertEquals(Math.sqrt(2.772589), LogLikelihood.rootLogLikelihoodRatio(1, 0, 0, 1), 0.000001);
assertEquals(-Math.sqrt(2.772589), LogLikelihood.rootLogLikelihoodRatio(0, 1, 1, 0), 0.000001);
assertEquals(Math.sqrt(27.72589), LogLikelihood.rootLogLikelihoodRatio(10, 0, 0, 10), 0.00001);

assertEquals(Math.sqrt(39.33052), LogLikelihood.rootLogLikelihoodRatio(5, 1995, 0, 100000), 0.00001);
assertEquals(-Math.sqrt(39.33052), LogLikelihood.rootLogLikelihoodRatio(0, 100000, 5, 1995), 0.00001);

assertEquals(Math.sqrt(4730.737), LogLikelihood.rootLogLikelihoodRatio(1000, 1995, 1000, 100000), 0.001);
assertEquals(-Math.sqrt(4730.737), LogLikelihood.rootLogLikelihoodRatio(1000, 100000, 1000, 1995), 0.001);

assertEquals(Math.sqrt(5734.343), LogLikelihood.rootLogLikelihoodRatio(1000, 1000, 1000, 100000), 0.001);
assertEquals(Math.sqrt(5714.932), LogLikelihood.rootLogLikelihoodRatio(1000, 1000, 1000, 99000), 0.001);
}

@Test
Expand Down

0 comments on commit a2375a3

Please sign in to comment.