<?php 
/** 
 * Test meansdev 
 * 
 * Submit a set of data to the meansdev object, calculate mean and standard 
 * deviation (sample standard deviation) 
 * @author cpks 
 * @package test 
 */ 
require 'meansdev.php'; 
 
use maths\statistics\meansdev; // import the meansdev class 
  
$data = array(14, 22, 11, 19, 30, 24); 
 
// select output format: we want mean and sdev, so this will do the trick: 
 
$formats = array('mean' => 'Mean: %.1f', 'sdev' => ", Standard deviation: %.2f\n"); 
 
// now create the meansdev object with our chosen format 
 
$m = new meansdev($formats); 
 
// crunch the sample data 
 
$m->multi_add($data); 
 
// and cough up the result: 
 
echo "$m\n"; 
/* This is equivalent to: 
printf("Mean: %.1f, Standard deviation: %.2f\n", $m->mean(), $m->stdev()); 
*/ 
 
 |