Need help resolving accidental (honest!) language pissing match

Jeff Epler jepler at unpythonic.net
Wed Jun 2 12:40:03 EDT 2004


Here's my try, using numarray:
    import numarray, numarray.random_array, numarray.nd_image
    n = 1000000
    x = numarray.random_array.randint(-1, 2, (n,))
    x = numarray.add.accumulate(x)
    mean = numarray.nd_image.mean(x)
    st_dev = numarray.nd_image.standard_deviation(x)
    print mean, st_dev
This runs for about .6 seconds on a 2.4GHz PC running Linux.

I'm not sure whether the results are right, but at least the program
finishes quickly, and involves a random array, a running sum, and some
statistics.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040602/52733456/attachment.sig>


More information about the Python-list mailing list