src/NGrams/Statistic2D.php
/**
    * Calculate the Loglikelihood coefficient
    * @param array $ngram Array of ngrams with frequencies
    * @return float Return the calculated value
    */
Calculate the Loglikelihood coefficient
@param array $ngram Array of ngrams with frequencies
@return float Return the calculated value
Calculate the Loglikelihood coefficient @param array $ngram Array of ngrams with frequencies @return float Return the calculated value
static public function ll(array $ngram, int $totalNgrams) : float
    {
        $var = self::setStatVariables($ngram, $totalNgrams);
        $logLikelihood = 0;
        if($var['jointFrequency']) {
            $logLikelihood += $var['jointFrequency'] * self::computePMI ( $var['jointFrequency'], $var['m11'] );
        }
        if($var['LminusJ']) {
            $logLikelihood += $var['LminusJ'] * self::computePMI( $var['LminusJ'], $var['m12'] );
        }
        if($var['RminusJ']) {
            $logLikelihood += $var['RminusJ']  * self::computePMI( $var['RminusJ'], $var['m21'] );
        }
        if($var['n22']) {
            $logLikelihood += $var['n22'] * self::computePMI( $var['n22'], $var['m22'] );
        }
        return $logLikelihood * 2;
    }
static public function ll ( array $ ngram , int $ totalNgrams ) : float { $ var = self :: setStatVariables ( $ ngram , $ totalNgrams ) ; $ logLikelihood = 0 ; if ( $ var [ 'jointFrequency' ] ) { $ logLikelihood += $ var [ 'jointFrequency' ] * self :: computePMI ( $ var [ 'jointFrequency' ] , $ var [ 'm11' ] ) ; } if ( $ var [ 'LminusJ' ] ) { $ logLikelihood += $ var [ 'LminusJ' ] * self :: computePMI ( $ var [ 'LminusJ' ] , $ var [ 'm12' ] ) ; } if ( $ var [ 'RminusJ' ] ) { $ logLikelihood += $ var [ 'RminusJ' ] * self :: computePMI ( $ var [ 'RminusJ' ] , $ var [ 'm21' ] ) ; } if ( $ var [ 'n22' ] ) { $ logLikelihood += $ var [ 'n22' ] * self :: computePMI ( $ var [ 'n22' ] , $ var [ 'm22' ] ) ; } return $ logLikelihood * 2 ; }
Calculate the Loglikelihood coefficient
 @param array $ngram Array of ngrams with frequencies
 @return float Return the calculated value
Calculate the Loglikelihood coefficient @param array $ngram Array of ngrams with frequencies @return float Return the calculated value