Package org.tribuo.util.infotheory.impl
Class TripleDistribution<T1,T2,T3>
java.lang.Object
org.tribuo.util.infotheory.impl.TripleDistribution<T1,T2,T3>
- Type Parameters:
T1
- Type of the first list.T2
- Type of the second list.T3
- Type of the third list.
Generates the counts for a triplet of vectors. Contains the joint
count, the three pairwise counts, and the three marginal counts.
Relies upon hashCode and equals to determine element equality for counting.
-
Field Summary
Modifier and TypeFieldDescriptionfinal long
The number of samples in this distribution.static final int
The default map size to initialise the marginalised count maps with. -
Constructor Summary
ConstructorDescriptionTripleDistribution
(long count, Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, Map<CachedPair<T1, T2>, com.oracle.labs.mlrg.olcut.util.MutableLong> abCount, Map<CachedPair<T1, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> acCount, Map<CachedPair<T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> bcCount, Map<T1, com.oracle.labs.mlrg.olcut.util.MutableLong> aCount, Map<T2, com.oracle.labs.mlrg.olcut.util.MutableLong> bCount, Map<T3, com.oracle.labs.mlrg.olcut.util.MutableLong> cCount) Constructs a triple distribution from the supplied distributions. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T1,
T2, T3> TripleDistribution<T1, T2, T3> constructFromLists
(List<T1> first, List<T2> second, List<T3> third) Constructs a TripleDistribution from three lists of the same length.static <T1,
T2, T3> TripleDistribution<T1, T2, T3> constructFromMap
(Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount) Constructs a TripleDistribution by marginalising the supplied joint distribution.static <T1,
T2, T3> TripleDistribution<T1, T2, T3> constructFromMap
(Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, int abSize, int acSize, int bcSize, int aSize, int bSize, int cSize) Constructs a TripleDistribution by marginalising the supplied joint distribution.static <T1,
T2, T3> TripleDistribution<T1, T2, T3> constructFromMap
(Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, Map<CachedPair<T1, T2>, com.oracle.labs.mlrg.olcut.util.MutableLong> abCount, Map<CachedPair<T1, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> acCount, Map<CachedPair<T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> bcCount, Map<T1, com.oracle.labs.mlrg.olcut.util.MutableLong> aCount, Map<T2, com.oracle.labs.mlrg.olcut.util.MutableLong> bCount, Map<T3, com.oracle.labs.mlrg.olcut.util.MutableLong> cCount) Constructs a TripleDistribution by marginalising the supplied joint distribution.Map<CachedPair<T1,
T2>, com.oracle.labs.mlrg.olcut.util.MutableLong> The joint distribution over the first and second variables.Map<CachedPair<T1,
T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> The joint distribution over the first and third variables.The marginal distribution over the first variable.Map<CachedPair<T2,
T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> The joint distribution over the second and third variables.The marginal distribution over the second variable.The marginal distribution over the third variable.Map<CachedTriple<T1,
T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> The joint distribution over the three variables.
-
Field Details
-
DEFAULT_MAP_SIZE
public static final int DEFAULT_MAP_SIZEThe default map size to initialise the marginalised count maps with.- See Also:
-
count
public final long countThe number of samples in this distribution.
-
-
Constructor Details
-
TripleDistribution
public TripleDistribution(long count, Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, Map<CachedPair<T1, T2>, com.oracle.labs.mlrg.olcut.util.MutableLong> abCount, Map<CachedPair<T1, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> acCount, Map<CachedPair<T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> bcCount, Map<T1, com.oracle.labs.mlrg.olcut.util.MutableLong> aCount, Map<T2, com.oracle.labs.mlrg.olcut.util.MutableLong> bCount, Map<T3, com.oracle.labs.mlrg.olcut.util.MutableLong> cCount) Constructs a triple distribution from the supplied distributions.- Parameters:
count
- The sample count.jointCount
- The joint distribution over the three variables.abCount
- The joint distribution over A and B.acCount
- The joint distribution over A and C.bcCount
- The joint distribution over B and C.aCount
- The marginal distribution over A.bCount
- The marginal distribution over B.cCount
- The marginal distribution over C.
-
-
Method Details
-
getJointCount
The joint distribution over the three variables.- Returns:
- The joint distribution.
-
getABCount
The joint distribution over the first and second variables.- Returns:
- The joint distribution over A and B.
-
getACCount
The joint distribution over the first and third variables.- Returns:
- The joint distribution over A and C.
-
getBCCount
The joint distribution over the second and third variables.- Returns:
- The joint distribution over B and C.
-
getACount
The marginal distribution over the first variable.- Returns:
- The marginal distribution for A.
-
getBCount
The marginal distribution over the second variable.- Returns:
- The marginal distribution for B.
-
getCCount
The marginal distribution over the third variable.- Returns:
- The marginal distribution for C.
-
constructFromLists
public static <T1,T2, TripleDistribution<T1,T3> T2, constructFromListsT3> (List<T1> first, List<T2> second, List<T3> third) Constructs a TripleDistribution from three lists of the same length.If they are not the same length it throws IllegalArgumentException.
- Type Parameters:
T1
- The first type.T2
- The second type.T3
- The third type.- Parameters:
first
- The first list.second
- The second list.third
- The third list.- Returns:
- The TripleDistribution.
-
constructFromMap
public static <T1,T2, TripleDistribution<T1,T3> T2, constructFromMapT3> (Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount) Constructs a TripleDistribution by marginalising the supplied joint distribution.- Type Parameters:
T1
- The type of A.T2
- The type of B.T3
- The type of C.- Parameters:
jointCount
- The joint distribution.- Returns:
- A TripleDistribution.
-
constructFromMap
public static <T1,T2, TripleDistribution<T1,T3> T2, constructFromMapT3> (Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, int abSize, int acSize, int bcSize, int aSize, int bSize, int cSize) Constructs a TripleDistribution by marginalising the supplied joint distribution.Sizes are used to preallocate the HashMaps.
- Type Parameters:
T1
- The type of A.T2
- The type of B.T3
- The type of C.- Parameters:
jointCount
- The joint distribution.abSize
- The number of unique AB states.acSize
- The number of unique AC states.bcSize
- The number of unique BC states.aSize
- The number of unique A states.bSize
- The number of unique B states.cSize
- The number of unique C states.- Returns:
- A TripleDistribution.
-
constructFromMap
public static <T1,T2, TripleDistribution<T1,T3> T2, constructFromMapT3> (Map<CachedTriple<T1, T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> jointCount, Map<CachedPair<T1, T2>, com.oracle.labs.mlrg.olcut.util.MutableLong> abCount, Map<CachedPair<T1, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> acCount, Map<CachedPair<T2, T3>, com.oracle.labs.mlrg.olcut.util.MutableLong> bcCount, Map<T1, com.oracle.labs.mlrg.olcut.util.MutableLong> aCount, Map<T2, com.oracle.labs.mlrg.olcut.util.MutableLong> bCount, Map<T3, com.oracle.labs.mlrg.olcut.util.MutableLong> cCount) Constructs a TripleDistribution by marginalising the supplied joint distribution.Sizes are used to preallocate the HashMaps.
- Type Parameters:
T1
- The type of A.T2
- The type of B.T3
- The type of C.- Parameters:
jointCount
- The joint distribution.abCount
- An empty hashmap for AB.acCount
- An empty hashmap for AC.bcCount
- An empty hashmap for BC.aCount
- An empty hashmap for A.bCount
- An empty hashmap for B.cCount
- An empty hashmap for C.- Returns:
- A TripleDistribution.
-