Sunday, February 27, 2011

Exploring chaos with Python

Having just written another small python script, I have a greater appreciation for python than I did before. This particular script explores how a certain function becomes chaotic for specific values of a coefficient. It's pretty simple, but the results are pretty interesting:
The above image is are some graphs of the system (see the link for more details) as it becomes chaotic. Python was pretty cool for this script because of the simplicity of generating the graphs. Using the NumPy and matplotlib libraries, generating the data set and graphing it is very straightforward. In fact, the code to plot is a simple oneliner:

plt.plot(xValues,yValues,',')

The two parameters are just lists of data values, and the "," character means that each data point is represented by a pixel on the graph. Everything else is handled by the plotting library.
Oh and one more very important thing: go grab the PyScripter IDE before any python development. It's a pretty nice tool and has what you would expect from an IDE (especially stepping through code in a debugger!). It even has support for unit testing.

No comments:

Post a Comment