Getting started¶
This guide takes you from zero to a first result in under 10 minutes.
Installation¶
Install via Composer:
composer require cjuol/statguard
Requirements: PHP 8.x.
First 10 minutes¶
Goal: compare the classic mean with a robust estimator and generate a quick report.
use Cjuol\StatGuard\RobustStats;
use Cjuol\StatGuard\StatsComparator;
$data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1000];
$robust = new RobustStats();
$mean = $robust->getMean($data);
$huber = $robust->getHuberMean($data);
$comparator = new StatsComparator();
$analysis = $comparator->analyze($data);
file_put_contents('report.json', $robust->toJson($data));
print_r([
'mean' => $mean,
'huber' => $huber,
'verdict' => $analysis['verdict'],
]);
What to expect: - The mean shifts because of the outlier. - Huber stays near the center. - The verdict flags bias from extreme values.
Next step¶
Go to the tutorials for full cases and recipes.