## Saturday, February 25, 2017

### Time to retirement

The essential idea behind this figure is that the fraction of your income that you save indicates two things -- 1. how much you are putting away each month, and 2. how little money you can live on. This number, which I'll call savings rate, is the one that is easiest for a worker to control. As a concrete example, let's say that Joe makes \$100,000 after taxes each year. If he saves \$10,000 each year, then his savings rate is 10%. OK, pretty simple so far. Now we need just one more number: the rate of return on investments. This is where my simplifying assumption comes in. Many people suggest that you withdraw no more than 4% of your savings each year in retirement, but they also maintain that you can expect to earn more than that in the stock market. To be conservative, I assume that you only earn 4% return on your investments annually. (If you're intersted, we'll see the impact of changing this number below.) I also assume that we're starting at the very begninning of our subject's career, so Joe has no money already saved, and that his income doesn't change over time. (Hopefully this is not the case, but it's safer not to count on big raises in the future.) Finally, our most stringent criterion: we want Joe to be able to live indefinitely in retirement, so he doesn't out-live his savings, and he'll have something for his kids to inherit. OK, those are the assumptions. By looking at the figure, we can see that at Joe's savings rate of 10%, he can retire after working for about 60 years. That doesn't sound very appealing, but I hope it is empowering to notice that if Joe manages to save 30%, or \$30,000 per year, he could retire safely in just 30 years!

Now, I promised that we could look into the effect of our assumption that the annual rate of return on investments is 4%. In the following figure I have plotted the results of this calculation for different rates of return. Note that these also assume the subject withdraws that amount every year in retirement, which might not be a good idea because it doesn't allow for bad years early in retirement.

I've also posted this analysis on my github site.

Disclosure: Nothing in this article should be construed as tax advice, a solicitation or offer, or recommendation, to buy or sell any security. This article is not intended as investment advice, and I do not represent in any manner that the circumstances described herein will result in any particular outcome. Past performance is no guarantee of future results.

## Friday, December 9, 2016

### Power analysis in A/B Tests

I recently wrote a very basic jupyter notebook demonstrating how to calculate the sample sizes necessary to detect a minimum effect size given desired false positive and false negative rates. I used a web site A/B test as an example, but the technique is generally applicable.

## Thursday, June 2, 2016

### Using Inkscape and FreeCad with Epilog Laser cutters

Our 75 watt Epilog Helix 24 is a tremendously useful piece of laboratory equipment for quickly prototyping or fabricating parts. Using it to cut out parts designed in Solidworks is fairly simple, but I was interested to see if it can be used with open source alternatives. Happily, the answer is yes!

## Inkscape

First of all, because laser cutting is essentially a 2-dimensional process, I wanted to be able to cut out designs produced in Inkscape, the premier open-source 2D drawing application. Because our Epilog has a 24"x18" cutting surface, I created a 24"x18" document, and then I drew the lines I wished to have cut. Now, to have the lines cut (instead of raster engraved) it is necessary to make all the line widths sufficiently small (under Fill and Stroke>Stroke style>Width). I chose .001 px. Unfortunately this makes them smaller than a pixel on most screens, but don't worry, they are still there. To actually send the file to the laser cutter, in Inkscape Windows Version 0.91, choose Extensions>Export>Win32 Vector Print. This brings up the Epilog print screen. Make sure the height and width match the document, and you are ready to cut!

 Laser cutting with Inkscape

Although Inkscape is great for quick 2D designs, for more complicated parts full 3D design software is necessary. FreeCad is starting to reach the point where it is ready for real use. After designing a part, it is easy to save an orthographic view to an svg file, then use the laser cutter to cut it out: First, select the part and go to the Drawing Workbench. From there you can create a new drawing, and add the orthographic projection. Finally, click the save drawing icon:

 Exporting from FreeCad to svg to cut on a Epilog laser cutter
The drawing is saved as an svg file. I had some trouble cutting designs from these files directly, but if you open the document we first created in Inkscape, then import the FreeCad file, it seems to work. After importing the part drawing, it is apparently necessary to select all the elements and convert them to paths:  go to Path>Object to Path. (I discovered this necessity because my part contained many circles, which were not getting cut by the laser cutter.) Now make sure your line widths are .001 pixels, and follow the directions above!

## Monday, April 4, 2016

### Photoreceptor paper accepted!

Our paper on polarization processing by photoreceptors is out in the Journal of Neuroscience! Here is some supplementary information that describes our process for mounting flies for simultaneous functional imaging and behavioral experiments.

## Wednesday, February 10, 2016

### Have gravitational waves been observed?

They certainly seem to be trending on Google searches:

Tune in tomorrow morning at 7:30 AM to hear an announcement from Caltech, MIT and the Laser Interferometer Gravitational-wave Observatory (LIGO): www.caltech.edu.

## Monday, February 8, 2016

### Changing font in matplotlib

In order to change the font of text in a matplotlib figure, I needed a list of the available fonts. It took me a frustratingly long time to find this stack exchange answer, so I thought I would record the solution here.
``` import matplotlib.font_manager {f.name for f in matplotlib.font_manager.fontManager.ttflist} ``` Then just choose a name from the set and insert it into a text command, e.g.
``` import matplotlib.pyplot as plt plt.ion() plt.title('title', fontname='FreeSans') ```

## Wednesday, December 2, 2015

### Programming new Reiser panels (G3)

I think I've mentioned the 'panels' that Michael Reiser developed while he was in Michael Dickinson's lab. These are widely used, but programming them can be a bit difficult and tedious. (By program, I mean upload the firmware to the panels themselves, not simply changing the address, which can be done easily over serial.) Will Dickson at iorodeo.com recently wrote a great little collection of shell scripts to make this process easier.

You will need a panel controller box, the panels you want to program, and an avrisp mkII.

First, plug the mkII usb into your computer and the female header side into the six-pin header on the front of the controller box:

Make sure to align the small arrow on the avrisp mkII with the arrow on the header:

Next, plug a panel face-up into the female header:

Now, download and unzip the scripts from Will's bitbucket site. In a terminal, cd into the iorodeo-panels_prog_avrdude/program directory. Finally, run

`./program_panel <address>`

``` import numpy as np np.set_printoptions(formatter={'int':lambda x:hex(int(x))}) print <address in decimal> ```