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