home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / ex_stats_cummulative_data.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.3 KB  |  61 lines

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net>                |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: ex_stats_cummulative_data.php,v 1.3 2003/01/04 11:55:39 mj Exp $
  20. //
  21.  
  22. /**
  23.  * @package    Math_Stats
  24.  */
  25.  
  26. require_once "Math/Stats.php";
  27.  
  28. // making some cummulative data sets
  29.  
  30. $data = array("3"=>4, "2.333"=>5, "1.22"=>6, "0.5"=>3, "0.9"=>2, "2.4"=>7);
  31. $dnulls = array("3"=>4, "caca"=>2, "bar is not foo"=>6, "0.5"=>3, "0.9"=>2, "2.4"=>7);
  32.  
  33. // instantiate a Math_Stats object
  34. $s = new Math_Stats();
  35. $s->setData($data, STATS_DATA_CUMMULATIVE);
  36.  
  37. echo "*** Original cummulative data set\n";
  38. print_r($data);
  39. // let's print some simple statistics
  40. echo "Simple stats from cummulative data, note the count\n";
  41. print_r($s->calcBasic());
  42.  
  43. // now, lets generate an error by using the $dnulls array
  44. echo "\n*** Another cummulative data set\n";
  45. print_r($dnulls);
  46. echo "Generating an error by using data with nulls\n";
  47. print_r($s->setData($dnulls, STATS_DATA_CUMMULATIVE));
  48.  
  49. // let's ignore nulls
  50. echo "Ignoring the nulls and trying again\n";
  51. $s->setNullOption(STATS_IGNORE_NULL);
  52. $s->setData($dnulls, STATS_DATA_CUMMULATIVE);
  53. print_r($s->calcBasic());
  54.  
  55. // let's assume null == zero
  56. echo "Assuming that nulls are zero\n";
  57. $s->setNullOption(STATS_USE_NULL_AS_ZERO);
  58. $s->setData($dnulls, STATS_DATA_CUMMULATIVE);
  59. print_r($s->calcFull());
  60. ?>
  61.