public class Similarity extends Object
SemanticSpace.| Modifier and Type | Class and Description |
|---|---|
static class |
Similarity.SimType
A type of similarity function to use when generating a
Method |
| Modifier and Type | Method and Description |
|---|---|
static double |
averageCommonFeatureRank(double[] a,
double[] b)
Computes the Average Common Feature Rank between the two feature arrays.
|
static double |
averageCommonFeatureRank(int[] a,
int[] b)
Computes the Average Common Feature Rank between the two feature arrays.
|
static double |
averageCommonFeatureRank(Vector a,
Vector b)
Computes the Average Common Feature Rank between the two feature arrays.
|
static double |
correlation(double[] arr1,
double[] arr2)
Returns the Pearson product-moment correlation coefficient of the two
arrays.
|
static double |
correlation(DoubleVector arr1,
DoubleVector arr2)
Returns the Pearson product-moment correlation coefficient of the two
Vectors. |
static double |
correlation(int[] arr1,
int[] arr2)
Returns the Pearson product-moment correlation coefficient of the two
arrays.
|
static double |
correlation(IntegerVector arr1,
DoubleVector arr2)
Returns the Pearson product-moment correlation coefficient of the two
Vectors. |
static double |
correlation(Vector a,
Vector b)
Returns the Pearson product-moment correlation coefficient of the two
Vectors. |
static double |
cosineSimilarity(double[] a,
double[] b)
Returns the cosine similarity of the two arrays.
|
static double |
cosineSimilarity(DoubleVector a,
DoubleVector b)
Returns the cosine similarity of the two
DoubleVector. |
static double |
cosineSimilarity(int[] a,
int[] b)
Returns the cosine similarity of the two arrays.
|
static double |
cosineSimilarity(IntegerVector a,
IntegerVector b)
Returns the cosine similarity of the two
DoubleVector. |
static double |
cosineSimilarity(Vector a,
Vector b)
Returns the cosine similarity of the two
DoubleVector. |
static double |
euclideanDistance(double[] a,
double[] b)
Returns the euclidian distance between two arrays of {code double}s.
|
static double |
euclideanDistance(DoubleVector a,
DoubleVector b)
Returns the euclidian distance between two
DoubleVectors. |
static double |
euclideanDistance(int[] a,
int[] b)
Returns the euclidian distance between two arrays of {code double}s.
|
static double |
euclideanDistance(IntegerVector a,
IntegerVector b)
Returns the euclidian distance between two
DoubleVectors. |
static double |
euclideanDistance(Vector a,
Vector b)
Returns the euclidian distance between two
Vectors. |
static double |
euclideanSimilarity(double[] a,
double[] b)
Returns the euclidian similiarty between two arrays of values.
|
static double |
euclideanSimilarity(int[] a,
int[] b)
Returns the euclidian similiarty between two arrays of values.
|
static double |
euclideanSimilarity(Vector a,
Vector b)
Returns the euclidian similiarty between two arrays of values.
|
static Method |
getMethod(Similarity.SimType similarityType)
Deprecated.
The
getSimilarity(SimType,double[],double[]) method
should be used instead.
Returns the Method for getting the similarity of two double[] based on the specified similarity type. |
static double |
getSimilarity(Similarity.SimType similarityType,
double[] a,
double[] b)
Calculates the similarity of the two vectors using the provided
similarity measure.
|
static <T extends Vector> |
getSimilarity(Similarity.SimType similarityType,
T a,
T b)
Calculates the similarity of the two vectors using the provided
similarity measure.
|
static SimilarityFunction |
getSimilarityFunction(Similarity.SimType similarityType) |
static double |
goodmanKruskalGamma(DoubleVector a,
DoubleVector b)
Computes the Goodman-Kruskal
Gamma coefficient, which is preferrable to Kendall's τ and
Spearman's ρ when there are many ties in the data.
|
static double |
jaccardIndex(double[] a,
double[] b)
Computes the Jaccard
index comparing the similarity both arrays when viewed as sets of
samples.
|
static double |
jaccardIndex(DoubleVector a,
DoubleVector b)
Computes the Jaccard
index comparing the similarity both
DoubleVectors when viewed
as sets of samples. |
static double |
jaccardIndex(int[] a,
int[] b)
Computes the Jaccard
index comparing the similarity both arrays when viewed as sets of
samples.
|
static double |
jaccardIndex(IntegerVector a,
IntegerVector b)
Computes the Jaccard
index comparing the similarity both
IntegerVectors when viewed
as sets of samples. |
static double |
jaccardIndex(Set<?> a,
Set<?> b)
Computes the Jaccard
index of the two sets of elements.
|
static double |
jaccardIndex(Vector a,
Vector b)
Computes the Jaccard
index comparing the similarity both
Vectors when viewed as
sets of samples. |
static double |
kendallsTau(double[] a,
double[] b)
Computes Kendall's
tau of the values in the two arrays.
|
static double |
kendallsTau(DoubleVector a,
DoubleVector b)
Computes Kendall's
tau of the values in the two vectors.
|
static double |
kendallsTau(int[] a,
int[] b)
Computes Kendall's
tau of the values in the two arrays.
|
static double |
kendallsTau(IntegerVector a,
IntegerVector b)
Computes Kendall's
tau of the values in the two vectors.
|
static double |
kendallsTau(Vector a,
Vector b)
Computes Kendall's
tau of the values in the two vectors.
|
static double |
klDivergence(double[] a,
double[] b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(DoubleVector a,
DoubleVector b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(int[] a,
int[] b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(IntegerVector a,
IntegerVector b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(Vector a,
Vector b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
linSimilarity(double[] a,
double[] b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(DoubleVector a,
DoubleVector b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(int[] a,
int[] b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(IntegerVector a,
IntegerVector b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(Vector a,
Vector b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
spearmanRankCorrelationCoefficient(double[] a,
double[] b)
Computes the Spearman rank correlation coefficient for the two arrays.
|
static double |
spearmanRankCorrelationCoefficient(DoubleVector a,
DoubleVector b)
Computes the Spearman rank correlation coefficient for the two
DoubleVectors. |
static double |
spearmanRankCorrelationCoefficient(int[] a,
int[] b)
Computes the Spearman rank correlation coefficient for the two arrays.
|
static double |
spearmanRankCorrelationCoefficient(IntegerVector a,
IntegerVector b)
Computes the Spearman rank correlation coefficient for the two
DoubleVectors. |
static double |
spearmanRankCorrelationCoefficient(Vector a,
Vector b)
Computes the Spearman rank correlation coefficient for the two
Vectors. |
static double |
tanimotoCoefficient(double[] a,
double[] b)
Returns the Tanimoto coefficient of the two
double array instances. |
static double |
tanimotoCoefficient(DoubleVector a,
DoubleVector b)
Returns the Tanimoto coefficient of the two
DoubleVector instances. |
static double |
tanimotoCoefficient(int[] a,
int[] b)
Returns the Tanimoto coefficient of the two
int array instances. |
static double |
tanimotoCoefficient(IntegerVector a,
IntegerVector b)
Returns the Tanimoto Coefficient of the two
IntegerVector
instances |
static double |
tanimotoCoefficient(Vector a,
Vector b)
Returns the Tanimoto coefficient of the two
Vector instances. |
@Deprecated public static Method getMethod(Similarity.SimType similarityType)
getSimilarity(SimType,double[],double[]) method
should be used instead.
Returns the Method for getting the similarity of two double[] based on the specified similarity type.Error - if a NoSuchMethodException is thrownpublic static SimilarityFunction getSimilarityFunction(Similarity.SimType similarityType)
public static double getSimilarity(Similarity.SimType similarityType, double[] a, double[] b)
similarityType - the similarity evaluation to use when comparing
a and ba - a vectorb - a vectorpublic static <T extends Vector> double getSimilarity(Similarity.SimType similarityType, T a, T b)
similarityType - the similarity evaluation to use when comparing
a and ba - a Vectorb - a Vectorpublic static double cosineSimilarity(double[] a,
double[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double cosineSimilarity(int[] a,
int[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double cosineSimilarity(DoubleVector a, DoubleVector b)
DoubleVector.public static double cosineSimilarity(IntegerVector a, IntegerVector b)
DoubleVector.IllegalArgumentException - when the length of the two vectors are
not the same.public static double cosineSimilarity(Vector a, Vector b)
DoubleVector.IllegalArgumentException - when the length of the two vectors are
not the same.public static double correlation(double[] arr1,
double[] arr2)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double correlation(int[] arr1,
int[] arr2)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double correlation(DoubleVector arr1, DoubleVector arr2)
Vectors.IllegalArgumentException - when the length of the two vectors are
not the same.public static double correlation(IntegerVector arr1, DoubleVector arr2)
Vectors.IllegalArgumentException - when the length of the two vectors are
not the same.public static double correlation(Vector a, Vector b)
Vectors.IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanDistance(double[] a,
double[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanDistance(int[] a,
int[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanDistance(DoubleVector a, DoubleVector b)
DoubleVectors.IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanDistance(IntegerVector a, IntegerVector b)
DoubleVectors.IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanDistance(Vector a, Vector b)
Vectors.IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanSimilarity(int[] a,
int[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanSimilarity(double[] a,
double[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double euclideanSimilarity(Vector a, Vector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double jaccardIndex(Set<?> a, Set<?> b)
public static double jaccardIndex(double[] a,
double[] b)
public static double jaccardIndex(int[] a,
int[] b)
public static double jaccardIndex(DoubleVector a, DoubleVector b)
DoubleVectors when viewed
as sets of samples.public static double jaccardIndex(IntegerVector a, IntegerVector b)
IntegerVectors when viewed
as sets of samples.public static double jaccardIndex(Vector a, Vector b)
Vectors when viewed as
sets of samples.public static double spearmanRankCorrelationCoefficient(double[] a,
double[] b)
a, then Pearson's
product-moment coefficient is returned instead.IllegalArgumentException - when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(int[] a,
int[] b)
a, then Pearson's
product-moment coefficient is returned instead.IllegalArgumentException - when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(DoubleVector a, DoubleVector b)
DoubleVectors. If there is a tie in the ranking of a, then
Pearson's product-moment coefficient is returned instead.IllegalArgumentException - when the length of the two vectors are
not the same.IllegalArgumentException - when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(IntegerVector a, IntegerVector b)
DoubleVectors. If there is a tie in the ranking of a, then
Pearson's product-moment coefficient is returned instead.IllegalArgumentException - when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(Vector a, Vector b)
Vectors. If there is a tie in the ranking of a, then Pearson's
product-moment coefficient is returned instead.IllegalArgumentException - when the length of the two vectors are
not the same.public static double averageCommonFeatureRank(double[] a,
double[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double averageCommonFeatureRank(Vector a, Vector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double averageCommonFeatureRank(int[] a,
int[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double linSimilarity(DoubleVector a, DoubleVector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double linSimilarity(IntegerVector a, IntegerVector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double linSimilarity(Vector a, Vector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double linSimilarity(double[] a,
double[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double linSimilarity(int[] a,
int[] b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double klDivergence(DoubleVector a, DoubleVector b)
A
and B where the vectors a and b correspond to
n samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException - when the length of the two vectors are
not the same.public static double klDivergence(IntegerVector a, IntegerVector b)
A
and B where the vectors a and b correspond to
n samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException - when the length of the two vectors are
not the same.public static double klDivergence(Vector a, Vector b)
A
and B where the vectors a and b correspond to
n samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException - when the length of the two vectors are
not the same.public static double klDivergence(double[] a,
double[] b)
A
and B where the vectors a and b correspond to
n samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException - when the length of the two vectors are
not the same.public static double klDivergence(int[] a,
int[] b)
A
and B where the vectors a and b correspond to
n samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException - when the length of the two vectors are
not the same.public static double kendallsTau(double[] a,
double[] b)
IllegalArgumentException - when the length of the two arrays are
not the same.public static double kendallsTau(int[] a,
int[] b)
IllegalArgumentException - when the length of the two arrays are
not the same.public static double kendallsTau(Vector a, Vector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double kendallsTau(DoubleVector a, DoubleVector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double kendallsTau(IntegerVector a, IntegerVector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double goodmanKruskalGamma(DoubleVector a, DoubleVector b)
IllegalArgumentException - when the length of the two vectors are
not the same.public static double tanimotoCoefficient(double[] a,
double[] b)
double array instances.IllegalArgumentException - when the length of the two arrays are
not the same.public static double tanimotoCoefficient(int[] a,
int[] b)
int array instances.IllegalArgumentException - when the length of the two arrays are
not the same.public static double tanimotoCoefficient(Vector a, Vector b)
Vector instances.IllegalArgumentException - when the length of the two vectors are
not the same.public static double tanimotoCoefficient(DoubleVector a, DoubleVector b)
DoubleVector instances.IllegalArgumentException - when the length of the two vectors are
not the same.public static double tanimotoCoefficient(IntegerVector a, IntegerVector b)
IntegerVector
instancesIllegalArgumentException - when the length of the two vectors are
not the same.Copyright © 2012. All Rights Reserved.