PHP Classes

File: meansdev_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  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: 3 years ago
Size: 756 bytes


Class file image Download
 * 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';

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


// and cough up the result:

echo "$m\n";
/* This is equivalent to:
printf("Mean: %.1f, Standard deviation: %.2f\n", $m->mean(), $m->stdev());