Login   Register  
PHP Classes
elePHPant
Icontem

File: test_hist.php3

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jesus M. Castagnetto  >  Histogram class  >  test_hist.php3  >  Download  
File: test_hist.php3
Role: ???
Content type: text/plain
Description: Sample code to use the Histogram class
Class: Histogram class
generate histograms from data set
Author: By
Last change:
Date: 14 years ago
Size: 1,151 bytes
 

Contents

Class file image Download
<HTML>
<BODY BGCOLOR="white">
<PRE>
<?php

require("class.hist");

/* 
 * Sample test code for the Histogram class
 * Jesus M. Castagnetto, 1999
 */

/* create a boring array */
$vals = array(
			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2,
			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2,
			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2
		);


/* create an instance w/o initialization */
$h = new Histogram;

/* do the calculation and print the results */
$h->create($vals,6,"Test 1");
$h->printStats();
$h->printBins();

/* access the result arrays directly*/

$result = $h->getBins();
echo "\n\nresult is of type: ".gettype($result)."\n";
while (list($key,$val) = each($result)) {
	echo $key."\t".$val."\n";
}

$result = $h->getStats();
echo "\n\nresult is of type: ".gettype($result)."\n";
while (list($key,$val) = each($result)) {
	echo $key."\t".$val."\n";
}

/* a new instance w/ initialization */
echo "\n\n============\n\n";
$k = new Histogram($vals,7,"Constructed histogram");
$k->printStats();
$k->printBins();

?>
</PRE>
</BODY></HTML>