PHP code example of ilicmiljan / weighted-ratings

1. Go to this page and download the library: Download ilicmiljan/weighted-ratings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ilicmiljan / weighted-ratings example snippets

 php
RatingWeightCalculator::FORMULA_WILSON_LOWER_BOUND
RatingWeightCalculator::FORMULA_BAYESIAN_APPROXIMATION
 php
$weightCalculator = new RatingWeightCalculator();

$ratingWeight = $weightCalculator->formula(RatingWeightCalculator::FORMULA_WILSON_LOWER_BOUND)
    ->calculateWeight([2,4,6,12,24]);
 php
$weightCalculator = new RatingWeightCalculator(
    new RatingWeightConfig(RatingWeightCalculator::FORMULA_WILSON_LOWER_BOUND, 5, 0.9)
);

$ratingWeight = $weightCalculator->calculateWeight([2,4,6,12,24,48,92,184,]);