public class MutualInformationVectorSimilarity extends java.lang.Object implements VectorSimilarity, java.io.Serializable
Similarity function that assumes the two vectors are paired samples from 2 correlated random variables. Using this we estimate the mutual information between the two variables.
Note, this uses the naive estimator of mutual information, which can be heavily biased when the two vectors have little overlap.
Constructor and Description |
---|
MutualInformationVectorSimilarity(Quantizer quantizer)
Construct a new mutual information similarity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isSparse()
Query whether this similarity function is sparse (returns 0 for vectors with disjoint key sets).
|
boolean |
isSymmetric()
Query whether this similarity function is symmetric.
|
double |
similarity(Long2DoubleMap vec1,
Long2DoubleMap vec2)
Compute the similarity between two vectors.
|
@Inject public MutualInformationVectorSimilarity(Quantizer quantizer)
Construct a new mutual information similarity.
quantizer
- A quantizer to allow discrete mutual information to be computed.public double similarity(Long2DoubleMap vec1, Long2DoubleMap vec2)
VectorSimilarity
Compute the similarity between two vectors.
similarity
in interface VectorSimilarity
vec1
- The left vector to compare.vec2
- The right vector to compare.public boolean isSparse()
VectorSimilarity
Query whether this similarity function is sparse (returns 0 for vectors with disjoint key sets).
isSparse
in interface VectorSimilarity
true
iff VectorSimilarity.similarity(Long2DoubleMap, Long2DoubleMap)
will always return true when applied to two vectors with no keys in common.public boolean isSymmetric()
VectorSimilarity
Query whether this similarity function is symmetric. Symmetric similarity functions return the same result when called on (A,B) and (B,A).
isSymmetric
in interface VectorSimilarity
true
if the function is symmetric.