src/NGrams/Statistic3D.php
/**
    * Calculate the Loglikelihood coefficient for trigrams
    * @param array $ngram Array of ngrams with frequencies
    * @return float Return the calculated value
    */
Calculate the Loglikelihood coefficient for trigrams
@param array $ngram Array of ngrams with frequencies
@return float Return the calculated value
Calculate the Loglikelihood coefficient for trigrams @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['e111'] );
        }
        if($var['n112']) {
            $logLikelihood += $var['n112'] * self::computePMI( $var['n112'], $var['e112'] );
        }
        if($var['n121']) {
            $logLikelihood += $var['n121']  * self::computePMI( $var['n121'], $var['e121'] );
        }
        if($var['n122']) {
            $logLikelihood += $var['n122'] * self::computePMI( $var['n122'], $var['e122'] );
        }
        if($var['n211']) {
            $logLikelihood += $var['n211'] * self::computePMI( $var['n211'], $var['e211'] );
        }
        if($var['n212']) {
            $logLikelihood += $var['n212'] * self::computePMI( $var['n212'], $var['e212'] );
        }
        if($var['n221']) {
            $logLikelihood += $var['n221'] * self::computePMI( $var['n221'], $var['e221'] );
        }
        if($var['n222']) {
            $logLikelihood += $var['n222'] * self::computePMI( $var['n222'], $var['e222'] );
        }
        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 [ 'e111' ] ) ; } if ( $ var [ 'n112' ] ) { $ logLikelihood += $ var [ 'n112' ] * self :: computePMI ( $ var [ 'n112' ] , $ var [ 'e112' ] ) ; } if ( $ var [ 'n121' ] ) { $ logLikelihood += $ var [ 'n121' ] * self :: computePMI ( $ var [ 'n121' ] , $ var [ 'e121' ] ) ; } if ( $ var [ 'n122' ] ) { $ logLikelihood += $ var [ 'n122' ] * self :: computePMI ( $ var [ 'n122' ] , $ var [ 'e122' ] ) ; } if ( $ var [ 'n211' ] ) { $ logLikelihood += $ var [ 'n211' ] * self :: computePMI ( $ var [ 'n211' ] , $ var [ 'e211' ] ) ; } if ( $ var [ 'n212' ] ) { $ logLikelihood += $ var [ 'n212' ] * self :: computePMI ( $ var [ 'n212' ] , $ var [ 'e212' ] ) ; } if ( $ var [ 'n221' ] ) { $ logLikelihood += $ var [ 'n221' ] * self :: computePMI ( $ var [ 'n221' ] , $ var [ 'e221' ] ) ; } if ( $ var [ 'n222' ] ) { $ logLikelihood += $ var [ 'n222' ] * self :: computePMI ( $ var [ 'n222' ] , $ var [ 'e222' ] ) ; } return ( $ logLikelihood * 2 ) ; }
Calculate the Loglikelihood coefficient for trigrams
 @param array $ngram Array of ngrams with frequencies
 @return float Return the calculated value
Calculate the Loglikelihood coefficient for trigrams @param array $ngram Array of ngrams with frequencies @return float Return the calculated value