A beginners code

(by Ronny Errmann)

As mentioned in my last post, I started coding without asking for advice. Which meant I would do things inefficiently. For example to calculate the standard deviation I used the following code:

mittel=sum(l for l in temp)/len(temp)
stdev=math.sqrt(sum((l-mittel)**2 for l in temp)/(len(temp)-1))

Later I learned about numpy, which made things a bit easier:

stdev = numpy.std(temp, ddof=1)

This is also quite a bit more efficient in computing time as it is run in compiled code and not has the overhead of an interpreter language.

Looking back I can smile about the code. In an interview I was once asked about that program if I would do things differently now. To which my answer was a clear yes.

One thought on “A beginners code

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 )

Facebook photo

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

Connecting to %s