Class WeightedPairDistribution<T1,T2>

java.lang.Object
org.tribuo.util.infotheory.impl.WeightedPairDistribution<T1,T2>
Type Parameters:
T1 - Type of the first list.
T2 - Type of the second list.

public class WeightedPairDistribution<T1,T2> extends Object
Generates the counts for a pair of vectors. Contains the joint count and the two marginal counts.
  • Field Details

    • count

      public final long count
      The sample count.
  • Constructor Details

    • WeightedPairDistribution

      public WeightedPairDistribution(long count, Map<CachedPair<T1,T2>,WeightCountTuple> jointCounts, Map<T1,WeightCountTuple> firstCount, Map<T2,WeightCountTuple> secondCount)
      Constructs a weighted pair distribution from the supplied values.

      Copies the maps out into LinkedHashMaps for iteration speed.

      Parameters:
      count - The sample count.
      jointCounts - The joint distribution.
      firstCount - The first marginal distribution.
      secondCount - The second marginal distribution.
    • WeightedPairDistribution

      public WeightedPairDistribution(long count, LinkedHashMap<CachedPair<T1,T2>,WeightCountTuple> jointCounts, LinkedHashMap<T1,WeightCountTuple> firstCount, LinkedHashMap<T2,WeightCountTuple> secondCount)
      Constructs a weighted pair distribution from the supplied values.
      Parameters:
      count - The sample count.
      jointCounts - The joint distribution.
      firstCount - The first marginal distribution.
      secondCount - The second marginal distribution.
  • Method Details

    • getJointCounts

      public Map<CachedPair<T1,T2>,WeightCountTuple> getJointCounts()
      Gets the joint distribution.
      Returns:
      The joint distribution.
    • getFirstCount

      public Map<T1,WeightCountTuple> getFirstCount()
      Gets the first marginal distribution.
      Returns:
      The first marginal distribution.
    • getSecondCount

      public Map<T2,WeightCountTuple> getSecondCount()
      Gets the second marginal distribution.
      Returns:
      The second marginal distribution.
    • constructFromLists

      public static <T1, T2> WeightedPairDistribution<T1,T2> constructFromLists(List<T1> first, List<T2> second, List<Double> weights)
      Generates the counts for two vectors. Returns a pair containing the joint count, and a pair of the two marginal counts.
      Type Parameters:
      T1 - Type of the first list.
      T2 - Type of the second list.
      Parameters:
      first - An list of values.
      second - Another list of values.
      weights - An list of per example weights.
      Returns:
      A WeightedPairDistribution.
    • constructFromMap

      public static <T1, T2> WeightedPairDistribution<T1,T2> constructFromMap(Map<CachedPair<T1,T2>,WeightCountTuple> jointCount)
      Generates a WeightedPairDistribution by generating the marginal distributions for the first and second elements. This assumes the weights have already been normalised.
      Type Parameters:
      T1 - Type of the first element.
      T2 - Type of the second element.
      Parameters:
      jointCount - The (normalised) input map.
      Returns:
      A WeightedPairDistribution