cvs: pear /Math_Stats Stats.php

From: Date: Fri, 24 May 2002 02:39:37 +0000
Subject: cvs: pear /Math_Stats Stats.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4068@lists.php.net to get a copy of this message
jmcastagnetto Thu May 23 22:39:37 2002 EDT Modified files: /pear/Math_Stats Stats.php Log: Added stdErrorOfMean() as well as a little more info on kurtosis and skewness Index: pear/Math_Stats/Stats.php diff -u pear/Math_Stats/Stats.php:1.7 pear/Math_Stats/Stats.php:1.8 --- pear/Math_Stats/Stats.php:1.7 Thu May 23 20:18:25 2002 +++ pear/Math_Stats/Stats.php Thu May 23 22:39:37 2002 @@ -16,7 +16,7 @@ // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Stats.php,v 1.7 2002/05/24 00:18:25 jmcastagnetto Exp $ +// $Id: Stats.php,v 1.8 2002/05/24 02:39:37 jmcastagnetto Exp $ // include_once "PEAR.php"; @@ -252,8 +252,9 @@ "mode" => $this->mode(), "midrange" => $this->midrange(), "stdev" => $this->stDev(), - "absDev" => $this->absDev(), + "absdev" => $this->absDev(), "variance" => $this->variance(), + "std_error_of_mean" => $this->stdErrorOfMean(), "skewness" => $this->skewness(), "kurtosis" => $this->kurtosis(), "coeff_of_variation" => $this->coeffOfVariation(), @@ -520,6 +521,11 @@ * Calculates the skewness of the data distribution in the set * The skewness measures the degree of asymmetry of a distribution, * and is related to the third central moment of a distribution. + * A normal distribution has a skewness = 0 + * A distribution with a tail off towards the high end of the scale + * (positive skew) has a skewness > 0 + * A distribution with a tail off towards the low end of the scale + * (negative skew) has a skewness < 0 * Handles cummulative data sets correctly * * @access public @@ -541,6 +547,10 @@ * The kurtosis measures the degrees of peakedness of a distribution. * It is also callesd the "excess" or "excess coefficient", and is * a normalized form of the fourth central moment of a distribution. + * A normal distributions has kurtosis = 0 + * A narrow and peaked (leptokurtic) distribution has a + * kurtosis > 0 + * A flat and wide (platykurtic) distribution has a kurtosis < 0 * Handles cummulative data sets correctly * * @access public @@ -681,6 +691,29 @@ if ($this->_data == null) return PEAR::raiseError("data has not been set"); return $this->stDev() / $this->mean(); + }/*}}}*/ + + /** + * Calculates the standard error of the mean. + * It is the standard deviation of the sampling distribution of + * the mean. The formula is: + * + * S.E. Mean = SD / (N)^(1/2) + * + * This formula does not assume a normal distribution, and shows + * that the size of the standard error of the mean is inversely + * proportional to the square root of the sample size. + * + * @access public + * @return mixed the standard error of the mean on success, a PEAR_Error object otherwise + * @see stDev() + * @see count() + * @see calc() + */ + function stdErrorOfMean() {/*{{{*/ + if ($this->_data == null) + return PEAR::raiseError("data has not been set"); + return $this->stDev() / sqrt($this->count()); }/*}}}*/ /**

« previous php.pear.cvs (#4068) next »