Esempio n. 1
0
def cosine_similarity(v, w):
    return dotProduct(v, w) / math.sqrt(dotProduct(v, v) * dotProduct(w, w))
Esempio n. 2
0
def transformVector(v, components):
    return [dotProduct(v, w) for w in components]
Esempio n. 3
0
def matrix_product_entry(A, B, i, j):
    return dotProduct(getRow(A, i), getCol(B, j))
Esempio n. 4
0
def __directionalVarianceGradiant(xi, w):
    projectionLength = dotProduct(xi, direction(w))
    return [2 * projectionLength * xij for xij in xi]
Esempio n. 5
0
def project(v, w):
    projectionLength = dotProduct(v, w)
    return scalarMultiply(projectionLength, w)
Esempio n. 6
0
def matrix_product_entry(A, B, i, j):
    return dotProduct(getRow(A, i), getCol(B, j))
Esempio n. 7
0
def __directionalVarianceI(xi, w):
    return dotProduct(xi, direction(w)) ** 2
Esempio n. 8
0
def transformVector(v, components):
    return [dotProduct(v, w) for w in components]
Esempio n. 9
0
def covariance(x, y):
    n = len(x)
    return dotProduct(de_mean(x), de_mean(y)) / (n - 1)
Esempio n. 10
0
def project(v, w):
    projectionLength = dotProduct(v, w)
    return scalarMultiply(projectionLength, w)
Esempio n. 11
0
def __directionalVarianceGradiant(xi, w):
    projectionLength = dotProduct(xi, direction(w))
    return [2 * projectionLength * xij for xij in xi]
Esempio n. 12
0
def __directionalVarianceI(xi, w):
    return dotProduct(xi, direction(w))**2
Esempio n. 13
0
def cosine_similarity(v, w):
    return dotProduct(v, w) / math.sqrt(dotProduct(v, v) * dotProduct(w, w))
Esempio n. 14
0
def covariance(x, y):
    n = len(x)
    return dotProduct(de_mean(x), de_mean(y)) / (n - 1)