# Statistical Calculations using Numpy

Blog Post created by Dan_Patterson on Jul 26, 2014

Update  2015-10-12

If you have installed ArcGIS Pro, then you have access to Python 3.4 which contains a useful statistics module... 9.7. statistics — Mathematical statistics functions — Python 3.4.3 documentation the focus provides some overlap with those presented here, but includes several useful sections dealing with centrality...specifically medians and mode.

--------------------------------------------------------------------------------------------------

This is a fuller version of how to determine statistical calculations using numpy.  A variety of statistical parameters and frequency distributions are calculated in the example.  These functions work with 1-D and 2-D lists.  2-D lists are flattened to 1-D lists prior to calculation making it useful to get otherwise unavailable stats for such data as grids.

This class is used in the "Field Statistics" for ArcGIS for those that wish to work in that environment or to obtain source codes for this and other functions.  The code etc, can be found in:

1  ArcGIS Online at Field Statistics  (http://www.arcgis.com/home/item.html?id=6c384f06c9f14d09920f4ff14460f4e2),

2  in the attachment below

The statistics include the usual but rarely quoted ones such mode, skewness and kurtosis by several means.  As well, functions to demonstrate how to determine several types of frequency distributions are presented.  The code includes some simple sample data so it can be run in standalone mode you can examine the outputs easily.  I make every attempt to write the code as verbose as possible so that non-programming students can view the logic contained in each function.  It also introduces the concept of classes in python for those that aren't familiar with it.  To use within your own code, examine the logic in the lines that follow the   if __name__ == "__main__":   section.