edu.umd.cloud9.util.count
Class OpenObject2IntConditionalFrequencyDistribution<K extends Comparable<K>>

java.lang.Object
  extended by edu.umd.cloud9.util.count.OpenObject2IntConditionalFrequencyDistribution<K>
All Implemented Interfaces:
Object2IntConditionalFrequencyDistribution<K>

public class OpenObject2IntConditionalFrequencyDistribution<K extends Comparable<K>>
extends Object
implements Object2IntConditionalFrequencyDistribution<K>

An implementation of a conditional frequency distribution for arbitrary events, backed by a fastutil open hash map. This class keeps track of frequencies using ints, so beware when dealing with a large number of observations.

Author:
Jimmy Lin

Constructor Summary
OpenObject2IntConditionalFrequencyDistribution()
           
 
Method Summary
 void check()
          Performs an internal consistency check of this data structure.
 int get(K k, K cond)
          Returns the observed frequency of k conditioned on cond.
 OpenObject2IntFrequencyDistribution<K> getConditionalDistribution(K cond)
          Returns the frequency distribution conditioned on cond.
 int getMarginalCount(K k)
          Returns the marginal count of k.
 long getSumOfAllFrequencies()
          Returns the sum of all frequencies.
 void increment(K k, K cond)
          Increments the observed frequency of k conditioned on cond.
 void increment(K k, K cond, int v)
          Increments the observed frequency of k conditioned on cond by v.
 void set(K k, K cond, int v)
          Sets the observed frequency of k conditioned on cond to v.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenObject2IntConditionalFrequencyDistribution

public OpenObject2IntConditionalFrequencyDistribution()
Method Detail

set

public void set(K k,
                K cond,
                int v)
Description copied from interface: Object2IntConditionalFrequencyDistribution
Sets the observed frequency of k conditioned on cond to v.

Specified by:
set in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>

increment

public void increment(K k,
                      K cond)
Description copied from interface: Object2IntConditionalFrequencyDistribution
Increments the observed frequency of k conditioned on cond.

Specified by:
increment in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>

increment

public void increment(K k,
                      K cond,
                      int v)
Description copied from interface: Object2IntConditionalFrequencyDistribution
Increments the observed frequency of k conditioned on cond by v.

Specified by:
increment in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>

get

public int get(K k,
               K cond)
Description copied from interface: Object2IntConditionalFrequencyDistribution
Returns the observed frequency of k conditioned on cond.

Specified by:
get in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>

getMarginalCount

public int getMarginalCount(K k)
Description copied from interface: Object2IntConditionalFrequencyDistribution
Returns the marginal count of k. That is, sum of counts of k conditioned on all cond.

Specified by:
getMarginalCount in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>

getConditionalDistribution

public OpenObject2IntFrequencyDistribution<K> getConditionalDistribution(K cond)
Description copied from interface: Object2IntConditionalFrequencyDistribution
Returns the frequency distribution conditioned on cond.

Specified by:
getConditionalDistribution in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>

getSumOfAllFrequencies

public long getSumOfAllFrequencies()
Description copied from interface: Object2IntConditionalFrequencyDistribution
Returns the sum of all frequencies.

Specified by:
getSumOfAllFrequencies in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>

check

public void check()
Description copied from interface: Object2IntConditionalFrequencyDistribution
Performs an internal consistency check of this data structure. An exception will be thrown if an error is found.

Specified by:
check in interface Object2IntConditionalFrequencyDistribution<K extends Comparable<K>>