# [Edu-sig] teaching Python

Daniel Ajoy dajoy at openworldlearning.org
Sun Nov 28 23:36:44 CET 2004

```I've always wanted to teach myself *inferential* statistics
through programming, but most of the examples of statistics
being taught through programming are *descriptive* statistics.

Most of the simple programs that you see in old BASIC books
that deal with statistics are, descriptive statistics.

Most *inferential* statistics algorithms are overly technical
or boring, and don't contribute to the understanding of
inferential statistics. Eg, chi-square-distribution algorithm.

I'm thinking that the problem arises because inferential
statistics deal with population with an infinite number of
members, or infinite many samples.

Daniel

On 28 Nov 2004 at 12:00, edu-sig-request at python.org wrote:

> For example, when doing stats, it's common to want a list of random numbers.
> It'd be useful to have a function with three parameters:  min and max to
> specify the range for the random integers, and a howmany.
>
>  >>> from random import randint
>  >>> def getrand(min, max, howmany):
>  	  return [randint(min,max) for i in range(howmany)]
>
>  >>> mylist = getrand(0,100,10)
>  >>> mylist
>  [0, 58, 53, 47, 89, 61, 60, 87, 12, 18]
>
> Then we could do stuff like:
>
>  >>> def mean(somelist):
>         return sum(somelist)/float(len(somelist))  # or use truedivision
>
>  >>> mean(mylist)
>  48.5
>
> Then on to standard deviation, divergence, and so on.  Very short programs.
> Lots of command line exploration.  Then save the short programs in a module
> for reuse later.
>

```