import math


def cosineSimilarity(a, b):
    """
    Compute the similarity between two vectors using the cosine similarity metric
    """
    dotProduct = 0
    aMagnitude = 0
    bMagnitude = 0
    for i in range(len(a)):
        dotProduct += (a[i] * b[i])
        aMagnitude += math.pow(a[i], 2)
        bMagnitude += math.pow(b[i], 2)

    aMagnitude = math.sqrt(aMagnitude)
    bMagnitude = math.sqrt(bMagnitude)

    return dotProduct / (aMagnitude * bMagnitude)