src/NGrams/Statistic2D.php
/**
    * Calculate the Mutual Information coefficient
    * @param array $ngram Array of ngrams with frequencies
    * @return float Return the calculated value
    */
Calculate the Mutual Information coefficient
@param array $ngram Array of ngrams with frequencies
@return float Return the calculated value
Calculate the Mutual Information coefficient @param array $ngram Array of ngrams with frequencies @return float Return the calculated value
static public function pmi(array $ngram, int $totalNgrams) : float
    {
        $var = self::setStatVariables($ngram, $totalNgrams);
        $temp = (($var['jointFrequency'] / $var['leftFrequency'] ) / $var['rightFrequency']) * $totalNgrams;
        return(log($temp)/log(2));
    }
static public function pmi ( array $ ngram , int $ totalNgrams ) : float { $ var = self :: setStatVariables ( $ ngram , $ totalNgrams ) ; $ temp = ( ( $ var [ 'jointFrequency' ] / $ var [ 'leftFrequency' ] ) / $ var [ 'rightFrequency' ] ) * $ totalNgrams ; return ( log ( $ temp ) / log ( 2 ) ) ; }
Calculate the Mutual Information coefficient
 @param array $ngram Array of ngrams with frequencies
 @return float Return the calculated value
Calculate the Mutual Information coefficient @param array $ngram Array of ngrams with frequencies @return float Return the calculated value