blob: 69170fb956975a69fdb2a04946d01964d2c08eca [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_121) on Fri Apr 14 22:10:59 PDT 2017 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LogLikelihood (Mahout Math 0.13.0 API)</title>
<meta name="date" content="2017-04-14">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="LogLikelihood (Mahout Math 0.13.0 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":9,"i3":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/LogLikelihood.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Class</li>
<li><a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.ScoredItem.html" title="class in org.apache.mahout.math.stats"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/mahout/math/stats/LogLikelihood.html" target="_top">Frames</a></li>
<li><a href="LogLikelihood.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.mahout.math.stats</div>
<h2 title="Class LogLikelihood" class="title">Class LogLikelihood</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.mahout.math.stats.LogLikelihood</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="typeNameLabel">LogLikelihood</span>
extends <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">Utility methods for working with log-likelihood</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.ScoredItem.html" title="class in org.apache.mahout.math.stats">LogLikelihood.ScoredItem</a>&lt;<a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.ScoredItem.html" title="type parameter in LogLikelihood.ScoredItem">T</a>&gt;</span></code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.ScoredItem.html" title="class in org.apache.mahout.math.stats">LogLikelihood.ScoredItem</a>&lt;T&gt;&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.html#compareFrequencies-com.google.common.collect.Multiset-com.google.common.collect.Multiset-int-double-">compareFrequencies</a></span>(com.google.common.collect.Multiset&lt;T&gt;&nbsp;a,
com.google.common.collect.Multiset&lt;T&gt;&nbsp;b,
int&nbsp;maxReturn,
double&nbsp;threshold)</code>
<div class="block">Compares two sets of counts to see which items are interestingly over-represented in the first
set.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.html#entropy-long...-">entropy</a></span>(long...&nbsp;elements)</code>
<div class="block">Calculates the unnormalized Shannon entropy.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.html#logLikelihoodRatio-long-long-long-long-">logLikelihoodRatio</a></span>(long&nbsp;k11,
long&nbsp;k12,
long&nbsp;k21,
long&nbsp;k22)</code>
<div class="block">Calculates the Raw Log-likelihood ratio for two events, call them A and B.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.html#rootLogLikelihoodRatio-long-long-long-long-">rootLogLikelihoodRatio</a></span>(long&nbsp;k11,
long&nbsp;k12,
long&nbsp;k21,
long&nbsp;k22)</code>
<div class="block">Calculates the root log-likelihood ratio for two events.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="entropy-long...-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>entropy</h4>
<pre>public static&nbsp;double&nbsp;entropy(long...&nbsp;elements)</pre>
<div class="block">Calculates the unnormalized Shannon entropy. This is
-sum x_i log x_i / N = -N sum x_i/N log x_i/N
where N = sum x_i
If the x's sum to 1, then this is the same as the normal
expression. Leaving this un-normalized makes working with
counts and computing the LLR easier.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The entropy value for the elements</dd>
</dl>
</li>
</ul>
<a name="logLikelihoodRatio-long-long-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>logLikelihoodRatio</h4>
<pre>public static&nbsp;double&nbsp;logLikelihoodRatio(long&nbsp;k11,
long&nbsp;k12,
long&nbsp;k21,
long&nbsp;k22)</pre>
<div class="block">Calculates the Raw Log-likelihood ratio for two events, call them A and B. Then we have:
<p/>
<table border="1" cellpadding="5" cellspacing="0">
<tbody><tr><td>&nbsp;</td><td>Event A</td><td>Everything but A</td></tr>
<tr><td>Event B</td><td>A and B together (k_11)</td><td>B, but not A (k_12)</td></tr>
<tr><td>Everything but B</td><td>A without B (k_21)</td><td>Neither A nor B (k_22)</td></tr></tbody>
</table></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k11</code> - The number of times the two events occurred together</dd>
<dd><code>k12</code> - The number of times the second event occurred WITHOUT the first event</dd>
<dd><code>k21</code> - The number of times the first event occurred WITHOUT the second event</dd>
<dd><code>k22</code> - The number of times something else occurred (i.e. was neither of these events</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The raw log-likelihood ratio
<p/>
Credit to http://tdunning.blogspot.com/2008/03/surprise-and-coincidence.html for the table and the descriptions.</dd>
</dl>
</li>
</ul>
<a name="rootLogLikelihoodRatio-long-long-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>rootLogLikelihoodRatio</h4>
<pre>public static&nbsp;double&nbsp;rootLogLikelihoodRatio(long&nbsp;k11,
long&nbsp;k12,
long&nbsp;k21,
long&nbsp;k22)</pre>
<div class="block">Calculates the root log-likelihood ratio for two events.
See <a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.html#logLikelihoodRatio-long-long-long-long-"><code>logLikelihoodRatio(long, long, long, long)</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k11</code> - The number of times the two events occurred together</dd>
<dd><code>k12</code> - The number of times the second event occurred WITHOUT the first event</dd>
<dd><code>k21</code> - The number of times the first event occurred WITHOUT the second event</dd>
<dd><code>k22</code> - The number of times something else occurred (i.e. was neither of these events</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The root log-likelihood ratio
<p/>
There is some more discussion here: http://s.apache.org/CGL
And see the response to Wataru's comment here:
http://tdunning.blogspot.com/2008/03/surprise-and-coincidence.html</dd>
</dl>
</li>
</ul>
<a name="compareFrequencies-com.google.common.collect.Multiset-com.google.common.collect.Multiset-int-double-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>compareFrequencies</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.ScoredItem.html" title="class in org.apache.mahout.math.stats">LogLikelihood.ScoredItem</a>&lt;T&gt;&gt;&nbsp;compareFrequencies(com.google.common.collect.Multiset&lt;T&gt;&nbsp;a,
com.google.common.collect.Multiset&lt;T&gt;&nbsp;b,
int&nbsp;maxReturn,
double&nbsp;threshold)</pre>
<div class="block">Compares two sets of counts to see which items are interestingly over-represented in the first
set.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - The first counts.</dd>
<dd><code>b</code> - The reference counts.</dd>
<dd><code>maxReturn</code> - The maximum number of items to return. Use maxReturn >= a.elementSet.size() to return all
scores above the threshold.</dd>
<dd><code>threshold</code> - The minimum score for items to be returned. Use 0 to return all items more common
in a than b. Use -Double.MAX_VALUE (not Double.MIN_VALUE !) to not use a threshold.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>A list of scored items with their scores.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/LogLikelihood.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Class</li>
<li><a href="../../../../../org/apache/mahout/math/stats/LogLikelihood.ScoredItem.html" title="class in org.apache.mahout.math.stats"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/mahout/math/stats/LogLikelihood.html" target="_top">Frames</a></li>
<li><a href="LogLikelihood.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2008&#x2013;2017 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>