WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Simple histogram class with a constructor and printing methods (updated 1999/03/26)
Categories : Algorithms, Math. Update Picture
Jesus M. Castagnetto
Date : Mar 27th 1999
Grade : 5 of 5 (graded 1 times)
Viewed : 3368
File : classes.php3.inc
Images : No Images for this code example.
Search : More code by Jesus M. Castagnetto
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

The class included in "classes.php3.inc" (see attached file),
can be used in calculation of simple stats and a histogram
distribution of an array of data.
Below is an example that uses this class.

<HTML>
<BODY BGCOLOR="white">
<PRE>
<?php

require("./classes.php3.inc");

/* Sample test code */

/* create a medium sized 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,
                        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,
                        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,
                        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,
                        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,
                        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->calc($vals,6,"COOL Test");
$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>



Library of math functions to expand the functionality of PHP3. Version 1.2.1 fixes a major problem with the gcd function.
Categories : Algorithms, PHP, Math.
Diffusion-Limited Aggregation visualization
Categories : PHP, Graphics, Algorithms, Math.
big fractional arithmetic
Categories : Algorithms, Math.
How to judge if an integer is odd or is even in Php3?
Categories : Math., PHP, Algorithms
Show the steps for converting a number from a given base to base 10. Shows the steps involved in converting a number from a given base to base 10.
Categories : PHP, Math., Algorithms
Get the root of a number with any precision
Categories : Algorithms, BC math, Math.
Prime Spiral is a image plotted with all the primes in a number spiral.
Categories : Algorithms, Graphics, GD image library, Math.
Reverse a given number
Categories : PHP, Beginner Guides, Algorithms, Math.
Prime number finder (Sieve of Erastothenes)
Categories : PHP, Algorithms, Math.
A very simple and efficient split bar the B-Z bar , for mysql and php ... Tired of obfuscated code try this one ...
Categories : PHP, Databases, MySQL, Algorithms
Weighted Random - Random Scripts usually chose one out of each item, and each item have an equal chance to be chosen. But what if you want an item to be chosed more frequently than other?
Categories : PHP, Math., Arrays
IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival.
Categories : PHP, Algorithms, Security, URLs
Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers.
Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms
Math operations on big numbers
Categories : PHP, Math.
Latitude-Longitude to Miles
Categories : PHP, Utilities, Math.