GraphAware\Reco4PHP\Algorithms\Similarity\CosineSimilarity::getSimilarity PHP Method

getSimilarity() public method

public getSimilarity ( array $xVector, array $yVector )
$xVector array
$yVector array
    public function getSimilarity(array $xVector, array $yVector)
    {
        $a = $this->getDotProduct($xVector, $yVector);
        $b = $this->getNorm($xVector) * $this->getNorm($yVector);
        if ($b > 0) {
            return $a / $b;
        }
        return 0;
    }