The Airy functions Ai(x) and Bi(x) are independent solutions to the differential equation For negative x they act something like sin(x) and cos(x). For positive x they act something like exp(x) and exp(-x). This isn’t surprising if you look at…

The Airy functions Ai(x) and Bi(x) are independent solutions to the differential equation For negative x they act something like sin(x) and cos(x). For positive x they act something like exp(x) and exp(-x). This isn’t surprising if you look at…

There’s no elementary formula for the circumference of an ellipse, but there is an elementary approximation that is extremely accurate. An ellipse has equation (x/a)² + (y/b)² = 1. If a = b, the ellipse reduces to a circle and…

A handful of dice can make a decent normal random number generator, good enough for classroom demonstrations. I wrote about this a while ago. My original post included Mathematica code for calculating how close to normal the distribution of the sum…

The Python stack for scientific computing is more modular than say R or Mathematica. Python is a general-purpose programming language that has libraries for scientific computing. R and Mathematica are statistical and mathematical programming languages that have general-purpose features. The…

This post reviews three Python books that have come out recently: SciPy and NumPy from O’Reilly Python for Kids: A Playful Introduction to Programming from No Starch Press NumPy Cookbook from Packt SciPy and NumPy by Eli Bressert is the…

Last night I was talking with someone about the pros and cons of various programming languages and frameworks for data analysis. One of the pros of Python is its elegance. The primary con is that it can be slow. The…

I recommend using Python for data analysis, and I recommend Wes McKinney’s book Python for Data Analysis. I prefer Python to R for mathematical computing because mathematical computing doesn’t exist in a vacuum; there’s always other stuff to do. I…

Statistical computing often involves working with ratios of factorials. These factorials are often too big to fit in a floating point number, and so we work with logarithms. So if we need to compute log(a! / b!), we call software…

Three years ago I wrote a post about my disappointment using SciPy with IronPython. A lot has changed since then, so I thought I’d write a short follow-up post. To install NumPy and SciPy for use with IronPython, follow the…

Last Friday I posted on @SciPyTip a summary of why I like SciPy, the scientific programming library for Python. I’d rather do math in a general-purpose language than try to do general-purpose programming in a math language. Mathematical software is…

Today I needed to compute an integral similar to this: I used the following SciPy code to compute the integral: from scipy.integrate import quad def f(x): return 0.01*x**-3 integral, error = quad(f, 1000, sp.inf, epsrel = 1e-6) print integral, error…

Isaac Newton suggested in 1687 that the earth is not a perfectly round sphere but rather an ellipsoid, and he was right. But since our planet is roughly a sphere, it’s often useful to approximate it by a sphere. So…

People are invariably surprised when they hear it’s hardly ever necessary to invert a matrix. It’s very often necessary solve linear systems of the form Ax = b, but in practice you almost never do this by inverting A. This…

The function jinc(x) that I wrote about yesterday is almost trivial to implement, but not quite. I’ll explain why it’s not quite as easy as it looks and how one might implement it in C and Python.

Imagine you picked up a dictionary and found that the pages with A’s were dirty and the Z’s were clean. In between there was a gradual transition with the pages becoming cleaner as you progressed through the alphabet. You might…