public function getEntropy()
    {
        if ('qwerty' === $this->graph || 'dvorak' === $this->graph) {
            $startingPos = $this->keyboardStartingPos;
            $avgDegree = $this->keyboardAvgDegree;
        } else {
            $startingPos = $this->keypadStartingPos;
            $avgDegree = $this->keypadAvgDegree;
        }

        $possibilities = 0;
        // estimate the number of possible patterns w/ token length or less with match turns or less.
        $tokenLength = strlen($this->token);
        for ($i = 2; $i <= $tokenLength; ++$i) {
            $possibleTurns = min($this->turns, $i - 1);

            for ($j = 1; $j <= $possibleTurns; ++$j) {
                $possibilities += $this->binom($i - 1, $j - 1) * $startingPos * ($avgDegree ** $j);
            }
        }
        $entropy = $this->log($possibilities);

        // add extra entropy for shifted keys. (% instead of 5, A instead of a.)
        if (!empty($this->shiftedCount)) {
            $possibilities = 0;
            $unshiftedCount = strlen($this->token) - $this->shiftedCount;
            $len = min($this->shiftedCount, $unshiftedCount);

            for ($i = 0; $i <= $len; ++$i) {
                $possibilities += $this->binom($this->shiftedCount + $unshiftedCount, $i);
            }
            $entropy += $this->log($possibilities);
        }

        return $entropy;
    }