Posts tagged ‘math’

March 31, 2011

Drawing Confidence Ellipses and Ellipsoids

by Lucas Wilkins

I’ve seen some really bad methods for drawing confidence ellipsoids recently, they all seem to make it really complicated and confusing (and specific). So I thought I would show how to calculate points on an ellipse corresponding to a covariance matrix – this method works for any number of dimensions without any need to change it.

For all those that don’t care why, the method to generate the points of an ellipsoid is as follows:

1) make a unit n-sphere (which for 2D is a circle with radius 1), call these points X:

If it is an elipse you want, make a matrix with columns of \sin(\theta) and \cos(\theta) for some incrementing \theta values between 0 and 2\pi(=)

2) apply the following linear transformation to get the points of your ellipsoid (Y):

Y = M + kC(\Sigma)X

where M is the vector of the means (center of the ellipsoid) and \Sigma is the covariance matrix. C represents the Cholesky Decomposition, sort of a matrix square root. k is the number of standard deviations at which one wishes to draw the ellipse

The Cholesky decomposition can be accessed as, “numpy.linalg.cholesky” in Python, “Cholesky” in R (matrix package), “chol” in MATLAB and “spotrf” (amongst others, I think) in LAPACK

For those who care, here is why this works…

March 30, 2011

Things that are annoying and should be done differently

by Nathaniel Virgo

Here are some well-established things that are being done wrong and should be changed.

1. \pi

Pi, that most fundamental of mathematical constants.  Except that pretty much whenever you see it in an equation it’s always got a 2 along with it.  This is because pi is defined as the ratio of a circle’s circumference to its diameter when it really should have been defined in relation to the radius instead.  That’s why there’s 2\pi radians in a circle instead of \pi, which would make more sense.

I was cheered to discover recently that there are others who share this opinion.  The link is to the “Tau Manifesto”.  They make a good argument that one should define a new circle constant represented by the Greek letter \tau (tau), such that \tau=2\pi.  I agree with their argument, but still sort-of prefer my own idea, which was to replace \pi by a new character which looks like one \pi stacked on top of another, like this:

= 2\pi

This character would be called “cake”, so the above equation would be read “cake equals 2 pie”.  Which is true.

2. Decibels


Get every new post delivered to your Inbox.

Join 480 other followers