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