Class PairDistribution<T1,T2>

java.lang.Object
org.tribuo.util.infotheory.impl.PairDistribution<T1,T2>
Type Parameters:
T1 - The type of the first element
T2 - The type of the second element

public class PairDistribution<T1,T2> extends Object
A count distribution over CachedPair objects.
  • Field Details

    • count

      public final long count
      The number of samples this distribution has seen.
    • jointCounts

      public final Map<CachedPair<T1,T2>,com.oracle.labs.mlrg.olcut.util.MutableLong> jointCounts
      The joint distribution.
    • firstCount

      public final Map<T1,com.oracle.labs.mlrg.olcut.util.MutableLong> firstCount
      The first marginal distribution.
    • secondCount

      public final Map<T2,com.oracle.labs.mlrg.olcut.util.MutableLong> secondCount
      The second marginal distribution.
  • Constructor Details

    • PairDistribution

      public PairDistribution(long count, Map<CachedPair<T1,T2>,com.oracle.labs.mlrg.olcut.util.MutableLong> jointCounts, Map<T1,com.oracle.labs.mlrg.olcut.util.MutableLong> firstCount, Map<T2,com.oracle.labs.mlrg.olcut.util.MutableLong> secondCount)
      Constructs a pair distribution.
      Parameters:
      count - The total sample count.
      jointCounts - The joint counts.
      firstCount - The first variable count.
      secondCount - The second variable count.
    • PairDistribution

      public PairDistribution(long count, LinkedHashMap<CachedPair<T1,T2>,com.oracle.labs.mlrg.olcut.util.MutableLong> jointCounts, LinkedHashMap<T1,com.oracle.labs.mlrg.olcut.util.MutableLong> firstCount, LinkedHashMap<T2,com.oracle.labs.mlrg.olcut.util.MutableLong> secondCount)
      Constructs a pair distribution.
      Parameters:
      count - The total sample count.
      jointCounts - The joint counts.
      firstCount - The first variable count.
      secondCount - The second variable count.
  • Method Details

    • constructFromLists

      public static <T1, T2> PairDistribution<T1,T2> constructFromLists(List<T1> first, List<T2> second)
      Generates the counts for two vectors. Returns a PairDistribution containing the joint count, and the two marginal counts.
      Type Parameters:
      T1 - Type of the first array.
      T2 - Type of the second array.
      Parameters:
      first - An array of values.
      second - Another array of values.
      Returns:
      The joint counts and the two marginal counts.
    • constructFromMap

      public static <T1, T2> PairDistribution<T1,T2> constructFromMap(Map<CachedPair<T1,T2>,com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount)
      Constructs a distribution from a joint count.
      Type Parameters:
      T1 - The type of the first variable.
      T2 - The type of the second variable.
      Parameters:
      jointCount - The joint count.
      Returns:
      A pair distribution.
    • constructFromMap

      public static <T1, T2> PairDistribution<T1,T2> constructFromMap(Map<CachedPair<T1,T2>,com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, int aSize, int bSize)
      Constructs a distribution from a joint count.
      Type Parameters:
      T1 - The type of the first variable.
      T2 - The type of the second variable.
      Parameters:
      jointCount - The joint count.
      aSize - The initial size of the first marginal hash map.
      bSize - The initial size of the second marginal hash map.
      Returns:
      A pair distribution.
    • constructFromMap

      public static <T1, T2> PairDistribution<T1,T2> constructFromMap(Map<CachedPair<T1,T2>,com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, Map<T1,com.oracle.labs.mlrg.olcut.util.MutableLong> aCount, Map<T2,com.oracle.labs.mlrg.olcut.util.MutableLong> bCount)
      Constructs a joint distribution from the counts.
      Type Parameters:
      T1 - The type of the first variable.
      T2 - The type of the second variable.
      Parameters:
      jointCount - The joint count.
      aCount - The first marginal count.
      bCount - The second marginal count.
      Returns:
      A pair distribution.