Modeling excitable media with cellular automata

While researching for my seminar I came across a class of cellular automata which models spiral waves in excitable media. Because these models are so simple I had some fun implementing them in processing. Processing is great because you can use the javascript version to embed the visualization in a webpage directly and everyone can play with it. Here are some of the models I played around with:

  • Spiral, a model developed by Gerhard and Schuster to simulate a chemical reaction.
  • CCA, a simple cyclic cellular automaton.
  • StochCCA, where I added stochasticity to the previous model. This is useful to assign more weight to the 4 neighbors of the Von Neumann neighborhood than to the remaining 4 which complete the Moore neighborhood. This appears to make space “more isotropic” and makes the waves actually circular.

Using Beautiful Soup to convert Springpad notes to Evernote

A few months back I decided to migrate all my work notes from springpad to evernote because I found evernote more robust and simpler. I still keep my recipe collection on springpad though! Looks yummy.

Anyway, surprisingly there were some scripts going from evernote to springpad but not the other way around, which is a bit suprising because both services use a sort of HTML notation to export their notes so it’s pretty simple to convert notes from one format to another. So I used the nice python library Beautiful Soup to parse the HTML and convert it to the other format.

With evernote it’s a bit tricky to get it to accept everything because any noncompliant HTML entity throws off the whole process, but after some trial and error I managed to fix it. As an aside, if you want a bit more power when editing your evernote notes, this service lets you directly edit the HTML of any note. It comes in pretty handy when you clip something from the web and it comes nested in some crazy divs. I hope evernote’s HTML format will not change too much in the near future and this script will stay helpful. In any case the header contains the evernote client version at the time, so I hope even if it changes they will recognize/honor the old version. Find the code after the jump.

Continue reading “Using Beautiful Soup to convert Springpad notes to Evernote”

An introduction to smoothing time series in python. Part II: wiener filter and smoothing splines

Wiener filter

The wiener filter is a bit more advanced than the filters I previously covered, as it is the first one rooted in probability theory. Consider a more complicated measurement, $y = r*s + n$, where $R$ is an operator describing the response of the measurement equipment (for images, it is known as point spread function). We want to find the signal estimate $\hat{s}$ which minimizes the distance $$E[(\hat{s}-s)^2]$$ i.e., the minimum mean square error. This estimate should be given for a linear filter $w$ such that $\hat{s} = w*y$.

Continue reading “An introduction to smoothing time series in python. Part II: wiener filter and smoothing splines”

An introduction to smoothing time series in python. Part I: filtering theory

Let’s say you have a bunch of time series data with some noise on top and want to get a reasonably clean signal out of that. Intuition tells us the easiest way to get out of this situation is to smooth out the noise in some way. Which is why the problem of recovering a signal from a set of time series data is called smoothing if we have data from all time points available to work with. This means we know $x_t$ for all $t\in[0,T]$. If we only know $x_t$ up to the current time point $t_n$, i.e. $t\in[0,t_n]$, then the problem is called filtering; and if we only have data for $t\in[0,t_{n-1}]$ the problem is called prediction. These three problems are closely related and the algorithms I’ll discuss are applicable to all problems with minor modifications. I’ll approach the problem from the smoothing perspective since that is what I need for my own research.

A signal corrupted with white noise. Bam!
A signal corrupted with white noise. Bam!
Continue reading “An introduction to smoothing time series in python. Part I: filtering theory”