Beginning The Nature Of Code

To carry on from the Processing work we did in class, I began to read the book The Nature of Code and start some of the exercises within it. The aim of the book is to teach the reader how to program how to model a digital “ecosystem” using concepts from biology and physics. I chose to look into this book to learn some more advanced programming skills and hopefully I can complete most of the assignements.

To start off the book talks about normal distribution and how in nature variable information usually lies along a bell curve. For example take people’s heights. The height of people can vary greatly, but if you looked at everyone’s heights as a data set, more people would be near the average height than at the two extremes. The mathematics behind this is called Gaussian distribution.

The equations for this are included in the Java library and a version of this is included in Processing. Take for example this code which uses Gaussian distribution to place white dots around a particular point.

gaussiancode gaussian

The lines generator.nextGaussian() creates a Gaussian distribution with ysd and xsd being the standard deviation and xmean and ymean being the mean. The circles are semi transparent so one can see the brighter areas near the middle where more of the dots are clustered, whereas on the outside the dots are more faint as they are less likely to be placed there.

Shiffman, D., 2012. The Nature of Code [online] Mountain View: Creative Commons.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s