PHP code example of assisted-mindfulness / bayesian-average
1. Go to this page and download the library: Download assisted-mindfulness/bayesian-average 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/ */
assisted-mindfulness / bayesian-average example snippets
// Item with a large number of ratings
$itemLargeRating = collect(range(0, 500))->transform(fn () => random_int(4, 5));
$itemLargeRatingAverage = $itemLargeRating->avg();
$itemLargeRatingCount = $itemLargeRating->count();
$c = 100; // Confidence number
$m = 3.5; // Catalog average
$bayes = new BayesianAverage();
$bayes
->setConfidenceNumber($c)
->setAverageRatingOfAllElements($m);
$bayes->getAverage($itemLargeRatingAverage, $itemLargeRatingCount); // ~4.3