# Weighted PHP Statistics: Calculate statistics on weighted data sets

 Version License PHP version Categories weightedstats 1.0.0 Freely Distributable 5 Algorithms, PHP 5, Statistics
Description

Author

This class can calculate statistics on weighted data sets.

It can take as parameters one data set array with numeric values and another array with the respective weights for the values in the first parameter array.

The class can calculate several types of common statistics on the data set values considering the weight values, like: the mean, average, standard deviation, percentile and skew.

Innovation Award
 May 2019 Number 5Prize: One subscription to the PDF edition of the PHP Architect magazine There are many types of statistical functions that can be applied to data sets like the mean, average, standard deviation, etc.. This class implements a variant version of those statistical functions by applying variable weights to each number value in the data set to which it is computing the values of those statistical functions. Manuel Lemos
 Performance Level
Name: Classes: Greg Neyman `` 2 packages by Greg Neyman United Kingdom 47 4206 187 in United Kingdom 213 5 in United Kingdom
Innovation award

Nominee: 2x

## Example

 ```

Weighted Statistics Class Example

"; print "
Arithmetic Mean
"; print "
The following is the incorrect mean for a weighted data set: "; print array_sum(\$inputs)/count(\$inputs); print "
Weighted Mean
"; print "
This is the correct way to perform the mean when the data provided has statistical weights: "; print \$ws->average(); print "
Standard Deviation
"; print \$ws->stdev(); print "
Quartile 1
"; print \$ws->percentile(25); print "
Median
"; print \$ws->percentile(50); print "
Quartile 3
"; print \$ws->percentile(75); print "
Skew
"; print \$ws->skew(); print "
"; ?> ```

## Details

 ```Many datasets have individual points which have differing weights than other points in the set. These datasets will include that information in a Weight column. Attempting to calculate statistics in a traditional way on such data will give incorrect results. This class has packaged the modified methods for common stats so they can be reliably performed when needed.```

 Files (3)
File Role Description
For more information send a message to `info at phpclasses dot org`.