Login   Register  
PHP Classes
elePHPant
Icontem

File: meansdev_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of CPK Smithies  >  meansdev  >  meansdev_test.php  >  Download  
File: meansdev_test.php
Role: Example script
Content type: text/plain
Description: Demonstrate class functionality
Class: meansdev
Calculate the mean, variance and deviation
Author: By
Last change:
Date: 2011-08-15 03:55
Size: 756 bytes
 

Contents

Class file image Download
<?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(142211193024);

// 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());
*/