Name |
Description |
cosineSimilarity
|
Computes the cosine similarity of input ranges a and b . The two ranges must have the same length. If both ranges define
length, the check is done once; otherwise, it is done at each
iteration. If either range has all-zero elements, return 0.
|
dotProduct
|
Computes the dot product of input ranges a and b . The two ranges must have the same length. If both ranges define
length, the check is done once; otherwise, it is done at each
iteration.
|
entropy
|
Computes entropy of input range r in bits. This
function assumes (without checking) that the values in r are all
in [0, 1] . For the entropy to be meaningful, often r should
be normalized too (i.e., its values should sum to 1). The
two-parameter version stops evaluating as soon as the intermediate
result is greater than or equal to max .
|
euclideanDistance
|
Computes Euclidean distance between input ranges a and
b . The two ranges must have the same length. The three-parameter
version stops computation as soon as the distance is greater than or
equal to limit (this is useful to save computation if a small
distance is sought).
|
fft
|
Convenience functions that create an Fft object , run the FFT or inverse
FFT and return the result. Useful for one-off FFTs.
|
findRoot
|
Find a real root of a real function f (x) via bracketing.
|
findRoot
|
Find root of a real function f (x) by bracketing, allowing the
termination condition to be specified.
|
findRoot
|
Find a real root of a real function f (x) via bracketing.
|
gapWeightedSimilarity
|
The so-called "all-lengths gap-weighted string kernel" computes a
similarity measure between s and t based on all of their
common subsequences of all lengths. Gapped subsequences are also
included.
|
gapWeightedSimilarityIncremental
|
Similar to gapWeightedSimilarity , just works in an incremental
manner by first revealing the matches of length 1, then gapped matches
of length 2, and so on. The memory requirement is Ο(s.length *
t.length ). The time complexity is Ο(s.length * t.length ) time
for computing each step. Continuing on the previous example:
|
gapWeightedSimilarityNormalized
|
The similarity per gapWeightedSimilarity has an issue in that it
grows with the lengths of the two strings, even though the strings are
not actually very similar. For example, the range ["Hello",
"world"] is increasingly similar with the range ["Hello",
"world", "world", "world",...] as more instances of "world" are
appended. To prevent that, gapWeightedSimilarityNormalized
computes a normalized version of the similarity that is computed as
gapWeightedSimilarity (s , t , lambda ) /
sqrt(gapWeightedSimilarity (s , t , lambda ) * gapWeightedSimilarity (s , t ,
lambda )) . The function gapWeightedSimilarityNormalized (a
so-called normalized kernel) is bounded in [0, 1] , reaches 0
only for ranges that don't match in any position, and 1 only for
identical ranges.
|
gcd
|
Computes the greatest common divisor of a and b by using
Euclid's algorithm.
|
inverseFft
|
Convenience functions that create an Fft object , run the FFT or inverse
FFT and return the result. Useful for one-off FFTs.
|
jensenShannonDivergence
|
Computes the Jensen-Shannon divergence between a and b , which is the sum (ai * log(2 * ai / (ai + bi)) + bi * log(2 *
bi / (ai + bi))) / 2 . The base of logarithm is 2. The ranges are
assumed to contain elements in [0, 1] . Usually the ranges are
normalized probability distributions, but this is not required or
checked by jensenShannonDivergence . If the inputs are normalized,
the result is bounded within [0, 1] . The three-parameter version
stops evaluations as soon as the intermediate result is greater than
or equal to limit .
|
kullbackLeiblerDivergence
|
Computes the Kullback-Leibler divergence between input ranges
a and b , which is the sum ai * log(ai / bi) . The base
of logarithm is 2. The ranges are assumed to contain elements in [0, 1] . Usually the ranges are normalized probability distributions,
but this is not required or checked by kullbackLeiblerDivergence . If any element bi is zero and the
corresponding element ai nonzero, returns infinity. (Otherwise,
if ai == 0 && bi == 0 , the term ai * log(ai / bi) is
considered zero.) If the inputs are normalized, the result is
positive.
|
normalize
|
Normalizes values in range by multiplying each element with a
number chosen such that values sum up to sum . If elements in range sum to zero, assigns sum / range.length to
all. Normalization makes sense only if all elements in range are
positive. normalize assumes that is the case without checking it.
|
sumOfLog2s
|
Compute the sum of binary logarithms of the input range r .
The error of this method is much smaller than with a naive sum of log2.
|