Old-school UNIX nerdery

I've never owned a Windows machine, or a Mac. It's not that I'm particularly hardcore about open source, it's just that I got used to a command line back in the old VIC-20/DOS/DesqView days and never really got away from it. Our undergrad computer network was very convenient, but made up of about four flavours of UNIX, and in fact they had a load-distributing program at login that meant your initial login was not just to a random machine but to a random UNIX flavour. Somehow the IT folks made this work tolerably well. After a few years of that, when I finally got a home computer, I chose to run Linux on it.


Full post

I for one welcome our new robot overlords

Fantastic Adventures 1941 Jan cover A common theme in science fiction is the idea that robots will take over our world. This doesn't seem very likely, but suppose it were to happen. What would the first steps look like? How would we first begin to notice that it was happening?


Full post

Police violence and crowd control

In the last few weeks, we've seen a number of events where large crowds of unruly people have gathered. Police response to these crowds has varied substantially, and I think it's instructive to think about what these responses say about us, as a society.


Full post

Getting health care

Like many universities, McGill offers a student health clinic. Unfortunately, it's almost impossible to actually access the services, even when the support staff aren't on strike. To actually get help, you have two options:
  • If it's not urgent: there is one day a month, usually but not always the 15th, on which you can make appointments for the following month. Any other time, tough luck.
  • If it's urgent: you can show up at 7 AM, stand outdoors until 8 AM, and hope you were early enough to get one of the very limited number of drop-in slips. This gets you in to see a randomly-assigned doctor, fora few hurried minutes. If it's for a prescription renewal, the chances are slim that they will know anything about you or your condition. Just cross your fingers and hope they're one of the competent ones.
If neither of those options suit you, well, go somewhere else. At least this is free, unless you want dentistry or vaccination or medication.



Full post

Lucky imaging

We have a telescope on the roof of the physics building. It's a fairly nice fourteen-inch Schmidt-Cassegrain telescope, though in fairly rough shape. Unfortunately, the physics building (and necessarily the telescope) is in the middle of downtown Montreal, which is a terrible place to look at the sky: bright lights, clouds, urban heat island, et cetera. So we have a telescope that collects lots of light but doesn't produce very sharp images. My attempt to work around this is described below.


Full post

Breaking out of iTunes

Since I got my "new" hand-me-down smart phone, I've been listening to a lot of podcasts. The phone is smart enough to use only my home wifi to update and download episodes, and the player keeps track of which ones I've read. This is so useful, in contrast to the music player, that I found it works better to keep my audiobooks on my home server and write a quick hack to serve them up as podcast feeds. But mostly I use podcasts like radio programs. Unfortunately, some podcasts are available only through iTunes. This makes sense if they cost money, but, for example, the NASA Lunar Science Institute has a free podcast which is only available through iTunes.

Fortunately it seems that the way these places get the data to iTunes is by serving up a standard RSS feed, which iTunes then wraps up in its proprietary glop. But Michael Sitarzewski helpfully put together a script that can extract the location of the original RSS from iTunes. So, for instance, you can subscribe to the NLSI podcast here. Very nice.


Full post

El Radar

I had the opportunity to visit the great radio telescope at Arecibo ("El Radar") last year. It's an astonishing machine, built more like a stadium than a telescope. Sadly, my digital camera died on that trip, so I don't have much in the way of pictures, but I came across this neat youtube clip (above). It's a segment from a BBC program, talking about dark matter and the role of Arecibo in understanding it. I thought it made a nice view of the telescope. I especially like that in some of the audio you can hear the coquì, little tree frogs that provide a constant chorus. (Of course the telescope is also in Contact and some James Bond film — surprisingly the latter provides a better view of the actual telescope.)

I'll talk a bit about the telescope and my own visit, with a few photos, below the jump.


Full post

The People's Microphone

I went down to Occupy Montreal the other day. It was pretty impressive, really; the modest park, surrounded by banks, was filled with tents and people making art. Particularly amusing was the statue of Queen Victoria wearing a Guy Fawkes mask (pictured on the right). But what got me thinking was the People's Microphone.


Full post

ssh shenanigans

I use ssh all the time, from simple terminal connections to VNC sessions controlling telescopes to rsyncing terabytes of data to serving my music and video library. Most of the time, the machine I actually want to connect to is not visible from the open internet, and in some cases there are two layers of machines to go through to get to the one I want. I have used various ad-hoc combinations of ssh connections, but I just found a brilliant library that solves several of my problems: paramiko.

(Also, the name is from Esperanto, and the releases are named after gashlycrumb tinies. This is some serious nerdery, here.)


Full post

Local Maxima and social annealing

Dan's Data has a new post/magazine article up, about local maxima. Frustratingly, there's no comment section, but I've been reading some interesting things that seem relevant, so I'll post them here. (TL;DR of Dan's post: socially we seem to get stuck in local maxima instead of finding the real best way to do things.)


Full post

Rest in peace, Dennis Ritchie

Dennis Ritchie, who created the C language, has died. It would be difficult to overstate the importance of his work — C is imperfect and limited, but it serves as a near-universal tool for programming everything from tiny ATTiny8s to Blue Gene supercomputers. It does exactly what it was designed to do — provide a portable abstraction that is nevertheless close enough to the underlying machine to be efficient, and comfortable enough to write substantial programs in. These days, I (and many other programmers) prefer to write in Python or another high-level language, but most interpreted languages are still implemented in C, and when performance is critical, C is generally the way to go. Dennis Ritchie's impact on the world of computers was tremendous, and he will be sorely missed.
From: Dennis Ritchie 
Newsgroups: comp.std.c
Subject: Re: Computing sizeof() during compilation
Organization: Bell Labs, Lucent Technologies

> You are right.  It was nice back in the days when things like
> 
> #if (sizeof(int) == 8)
> 
> actually worked (on some compilers).

Must have been before my time.

 Dennis

Full post

Curve fitting part 5: PyMC

I previously talked about fitting a curve to data — specifically, a sinusoid-plus-constant to a distribution of photon arrival times. I wrote some special-purpose Bayesian code to evaluate the relevant integrals directly so that I could work out the posterior distribution of fitted parameters. As a bonus I was also able to test the hypothesis that the photons were pulsed. Unfortunately, the method I used really doesn't generalize to more complicated situations. Fortunately, there is a toolkit that does: PyMC.
PyMC provides tools to implement Markov Chain Monte Carlo algorithms. These evaluate probability integrals numerically by generating samples from the distribution. They do this fairly efficiently by "jumping" semi-randomly from point to point in the space, but jumping preferentially towards points that are more likely. The algorithm is carefully arranged so that, after a certain number of steps, the initial guess is forgotten and the points are correctly distributed. They are correlated, but the correlations can be reduced or eliminated by subsampling the sequence. It's complex, finicky code. Fortunately I don't need to write it, because the algorithm is sufficiently generic that with PyMC all I have to do is specify the model I'm trying to fit. And, sure enough, it works. Code and results below the jump. The short version is: PyMC is easy to use and well-documented.
The second half of my previous post, model selection, turns out to be a little trickier to implement with Markov Chain Monte Carlo; I'll address that in a later post.

Full post

Testing whether a signal is broad-band

Radio pulsars are generally broad-band sources — you can hear them over a very wide range of radio frequencies, from about a hundred megahertz up to, in a few cases, tens of gigahertz. Their emission does change with frequency, decreasing as a power law, but over reasonable bandwidths we expect to see their signal in all frequency channels.


Radio-frequency interference ("RFI"), on the other hand, is very frequently narrow-band, appearing in just one, or a few frequency channels. In fact, one way we try to manage RFI is by using really wide bandwidths, so that there's so much power from the pulsar signal that narrow-band RFI is drowned out. Unfortunately, all too often the RFI is so strong that even a narrow-band signal can dominate the total power. And since it's narrow-band, dedispersion doesn't smear it out like it would a broad-band interference spike. So narrow-band RFI is one of the kinds of interference that is particularly hard to sift out from pulsar candidates.

Just recently, on the arxiv, a paper came out that attempts to address the problem of testing whether a candidate is broad-band:
Multimoment Radio Transient Detection
Laura Spitler, Jim Cordes, Shami Chatterjee, Julia Stone
We present a multimoment technique for signal classification and apply it to the detection of fast radio transients in incoherently dedispersed data. Specifically, we define a spectral modulation index in terms of the fractional variation in intensity across a spectrum. A signal whose intensity is distributed evenly across the entire band has a much lower modulation index than a spectrum with the same intensity localized in a single channel. We are interested in broadband pulses and use the modulation index to excise narrowband radio frequency interference (RFI) by applying a modulation index threshold above which candidate events are removed. The technique is tested both with simulations and using data from sources of known radio pulses (RRAT J1928+15 and giant pulses from the Crab pulsar). We find that our technique is effective at eliminating not only narrowband RFI but also spurious signals from bright, real pulses that are dedispersed at incorrect dispersion measures. The method is generalized to coherent dedispersion, image cubes, and astrophysical narrowband signals that are steady in time. We suggest that the modulation index, along with other statistics using higher-order moments, should be incorporated into signal detection pipelines to characterize and classify signals.
This looks very promising, but there's some testing I wish they'd done. More on the subject below the jump.



Full post

Contraceptive underwear update

I did a little more looking for information on the use of special underwear as a form of male contraception. In particular I went and found the 1994 Mieusset and Bujan paper. Unfortunately for some reason McGill's subscription does not cover online access to the International Journal of Andrology, so I had to go down into the literally dusty bowels of the library. To give you some idea what I was dealing with, I picked this no-doubt fascinating book off the shelves at random:



Don't worry, the actual paper is rather less ancient, though it was in an obscure enough journal to be in the rolling stacks — gear handles and all. But find it I did, and while they sadly don't have a photo of the contraceptive underwear, they do have a diagram. Since it is conceivably NSFW, I'll put it below the jump.


Full post

ipython notebooks: second impressions

I've kept working with ipython's notebook mode; it really is very well suited to my python-as-a-scratchpad style of figuring certain things out. So I've come up with a few more comments:
  • SVG plots work fine and look better, at least for modestly-sized output (thousands of points on a plot, megapixel images). They're also bigger on the screen, for some reason.
  • Be careful with commands that generate a lot of output; they can make your browser grind to a halt while it tries to render the output of that debugging print statement in that inner loop. During this time you also can't save your document. It might be nice if ipython noticed giant output and collapsed it.
  • It would sometimes be nice to be able to collapse blocks down to a little plus sign. For example, the first block normally needs to be the imports and maybe some ipython boilerplate (setting SVG mode, for example). It'd be nice to be able to hide it while working on the rest of the document.
  • It'd be nice to be able to break up class definitions into multiple blocks (for example to be able to have rendered math explanations for each method).
  • In PNG mode, the images are included using data URIs. This doesn't work on the very old web browser I have at work.
  • If you start pushing the memory limits of your machine it can be very hard to interact with the browser enough to kill the kernel.
For me, the most important of these is embedding the output in a blog post. It already sort of works: SVG is embedded in the output HTML, and PNG is encoded in a data: URI, so it's almost enough to strip out all the contents of the body tag and paste them into an HTML editor. Of course proper display depends on CSS, but I've added all the CSS that seemed relevant into the "custom CSS" field of my blog. The output still has some weird spacing issues; in particular, input blocks are all the same height for some reason.

Edited to add: notebooks have improved a lot since this review. I'm going to write another soon.

Full post

Digital in the Facebook age

Some time ago I posted about a lovely retrocomputing-style ren'ai game called "Digital: a Love Story". The same author has pubished a sequel, titled "don't take it personally, babe, it just ain't your story". It too is lovely, and has something interesting to say about privacy. If you haven't played ren'ai, be aware that it does have some genre conventions that take some getting used to, but it is a medium in which clever writing can produce a fascinating immersive story. In this case with dollops of facebook and 4chan.


Full post

Faster-than-light neutrinos: keeping time

There's been a recent announcement of evidence that muon neutrinos may travel faster than light. That would be really weird - in particular it would pose serious problems for Einstein's theories of relativity. But even the discoverers aren't ready to claim that; they just describe their results and say they're puzzling. Personally I think it's unlikely they're right, but figuring out why not may be very interesting.


Faster than Light? par CNRS

Fortunately for us, they have posted a preprint of their paper on arxiv.org. All images below are from that paper.

I can't say much about the particle physics, or the details of instrument calibration, but I can address one possible way people have suggested the result may be wrong: inaccuracies in the time standards at the two endpoints.


Full post

A captcha problem

Hmm. Think it would cope with \( M_2(\mathbb{Z})\tilde m \)? Or $M_2(\mathbb{Z})\tilde m$? Or just plain M_2(\mathbb{Z})\tilde m? In principle it might, since recaptcha is crowd-sourced; if I came up with the same LaTeX representation all previous recaptcha users had, all would be fine...

Full post

Male contraception

The Pill — hormonal contraception for women — is sometimes credited with making possible the sexual revolution. There is as yet no hormonal contraception for men. My feeling is that this is for real biological reasons — the female reproductive system is more complicated and easier to interfere with. And of course in the era of HIV/AIDS and other STIs, condoms have a unique role. Other methods of contraception remain important. There's a new supposedly-reversible one for men and there's always vasectomy. But there's another method for men that I'd never heard of, but find amusing: testicular heating.
[update — pictures! sort of]


Full post

Source Code

No, I mean the movie. It's science fiction, of the Twilight Zone flavour: soft, set here and now, and with a little pointed topical relevance. Jake Gyllenhaal plays a soldier who gets sent into the "Source Code", eight minutes before a terrorist attack, and told that he must do whatever he can to figure out who the bomber is. He can retry it as many times as he likes. It's very like the brilliant interactive fiction Varicella (described below the jump).


Full post

The Core

I've worked with data from X-ray satellites before, and among the many messy things one has to deal with in real data were blocks of time marked SAA. I knew this stood for "South Atlantic Anomaly", but I had only the vague idea that it was a part of the sky that was geomagnetically inconvenient, so that I had to trim it out of my data. The other day I came across a fascinating BBC documentary, titled "The Core":

This documentary talks about the Earth's core and how we're studying it, from seismology to diamond anvils to huge liquid-sodium dynamo experiments. It makes very interesting watching, but I particularly liked that they used the South Atlantic Anomaly as a hook: it caused problems with certain instruments on Hubble, and the documentary is framed as an investigation into why. (More below the jump if you're not worried about spoilers.)


Full post

Mathjax

When looking at the ipython notebook interface, I came across a neat tool: mathjax. It's designed to allow embedding math in web documents. Now, MathML was supposed to do this, but support for MathML is still very spotty, and it's also really nasty trying to write MathML manually. So mathjax allows you to simply enter TeX format math and have it look okay in supposedly all browsers: both inline as \(e^{i\pi}=-1\) and displayed as $$\int_{-\infty}^{\infty}f(t)e^{2\pi i f t}dt. $$

The way that it does this is kind of amazing to me: it's essentially a TeX renderer written in javascript and running in your browser. I'm used to thinking of TeX as a batch-mode compiler that takes an appreciable time to run, but TeX has become the de facto standard way to write mathematics, and there are now several reimplementations of its renderer. Matplotlib has one, for example, though it can also call out to real TeX if you ask it to. But javascript!

Anyway, as you can see above, I've added it to the template for this blog, so I'll be a little freer with math from now on. Though I'm willing to bet it doesn't work in the RSS feed. Let me know if you have any problems with it.

Full post

Review: ipython notebooks

The development version of ipython recently added a "notebook" interface mode. This resembles the interface of MAPLE or Mathematica, in which you can intermingle blocks of formatted text, blocks of code and output, and plots. My feeling, after working with it for a bit, is that it is very well suited to the kind of work I do when (for example) writing blog posts demonstrating some algorithm. For developing actual reusable software, not so much.

In order to give it a proper test, I applied it to a problem that a friend asked me about. It's about the card game Set: how often do you run into a tableau with no sets? The game quotes a figure of one time in 25, but that's for tableaux dealt from scratch. As you play the game, you remove and replace sets, and it often seems as if no-set tableaux arise more often when the cards are not freshly-dealt. The game's rules are a lovely minimalist mathematical exercise, but once you start removing and replacing cards an analytical solution becomes impractical. Simulation to the rescue! And this seemed like a nice test problem for ipython.

You can see the results here (PDF). For my comments on ipython, read on.

Edited to add: notebooks have improved a lot since this review, or the later one.

Full post

Least squares and timing noise, part 2

Simulated time series
In my previous post I described a new paper about fitting pulsar parameters in the presence of timing noise using a general least-squares method. It seems like a good approach, but I'd like to look at it in more detail. So: python to the rescue!


Full post

The Mechanical Microbiologist

Laboratory automation has been growing more and more elaborate - multiwell tools for "parallel processing", and benchtop robot arms, for example, that will handle repetitive tasks. But flow cytometry offers some startling possibilities.


Full post

Least-squares and timing noise

Figure 4 from the paper: residuals and spectrum
Working with long-term pulsar timing data sets is a nuisance because of so-called "timing noise". Not only is this noise above and beyond the usual observational uncertainties, perhaps because it is torque noise, it tends to be strongest at low frequencies (it is very "red"). Often so much so that leakage from the very lowest frequencies dominates at all analysis frequencies. Various people, myself included, have tried various approaches for dealing with this noise, but a recent arxiv paper shows real promise:

Pulsar timing analysis in the presence of correlated noise
Pulsar timing observations are usually analysed with least-square-fitting procedures under the assumption that the timing residuals are uncorrelated (statistically "white"). Pulsar observers are well aware that this assumption often breaks down and causes severe errors in estimating the parameters of the timing model and their uncertainties. Ad hoc methods for minimizing these errors have been developed, but we show that they are far from optimal. Compensation for temporal correlation can be done optimally if the covariance matrix of the residuals is known using a linear transformation that whitens both the residuals and the timing model. We adopt a transformation based on the Cholesky decomposition of the covariance matrix, but the transformation is not unique. We show how to estimate the covariance matrix with sufficient accuracy to optimize the pulsar timing analysis. We also show how to apply this procedure to estimate the spectrum of any time series with a steep red power-law spectrum, including those with irregular sampling and variable error bars, which are otherwise very difficult to analyse.
I'd like to look at it in more detail and try some of the techniques on test data.


Full post

Radio vortices



Quantum mechanics, no one will be surprised to hear, is weird. In particular, photons can carry angular momentum - circularly polarized light can set objects spinning. But it turns out that light can carry orbital angular momentum as well. It's really not very clear to me quite what this means in terms of photons. In terms of classical waves, it's weird but I think I get it: if you look at the spatial distribution of the light in a beam, you may find that the phase is constant across the whole beam. But you might also find that the phase varies. Now, it has to be continuous, but you can imagine that as you make a circle around the beam center, you find the phase increases by an integer multiple of two pi. This gives you a continuous phase in a way that is topologically different from the constant-phase situation. As I understand it, this is what is called wrapping number.

Now this would just be another weirdness from the world of (classical!) waves except that there seem to be applications for it. In particular there's a paper on the arxiv about using this for communications purposes.


Full post

Science fiction has no imagination, part 1

Every so often I come across something that makes me think that the supposedly imaginative field of science fiction can't hold a candle to reality for weirdness. Today's installment is an arxiv paper in which the authors are seriously discussing quantum teleportation as a way to combine signals from telescopes to form an interferometer:


Longer-Baseline Telescopes Using Quantum Repeaters

Daniel Gottesman, Thomas Jennewein, Sarah Croke

We present an approach to building interferometric telescopes using ideas of quantum information. Current optical interferometers have limited baseline lengths, and thus limited resolution, because of noise and loss of signal due to the transmission of photons between the telescopes. The technology of quantum repeaters has the potential to eliminate this limit, allowing in principle interferometers with arbitrarily long baselines.

Full post