echo versus printf

Quick Note: When you’re bash scripting and you need to pipe some text into some process, you can use echo with the -n flag to suppress the echo‘s complimentary endline , or you can use printf, but using printf is more portable. Some machines implement echo differently and don’t support the -n flag. I found this advice and a longer explanation at this message board.

Viewing Shapefiles Using Basemap in Python

I heard about a new (to me) tool for viewing shapefiles on this site. It required the installation of basemap which is a part of matplotlib, but the installation turned out to be a little tricky. I found a solution at the blog, I Lessen Data, which pointed me to another interesting post on mapping, So You’d Like to Make a Map Using Python.

Continue reading Viewing Shapefiles Using Basemap in Python

Time Series Forecasting in Python and R

A friend recently made a prediction about the price of oil for the next three months. I thought I would perform some time series forecasting on the West Texas Intermediate prices and see if his numbers were reasonable from a dumb-numbers canned-forecasting perspective. I’m not making the claim that one can reasonably and accurately forecast oil prices with traditional time series techniques. (That’s bogus.) I’m simply doing this to learn more about forecasting.

Monthly petroleum prices can be found at the Energy Information Administration. Ever relevant, Wikipedia has a great write-up on recent trends in oil prices. Also, there is this Times article on the spike and drop in 2008 which had this apt summary,

[Oil prices are] the product of an extremely volatile mixture of speculation, oil production, weather, government policies, the global economy, the number of miles the average American is driving in any given week and so on. But the daily price is actually set — or discovered, in economic parlance — on the futures exchange.

Continue reading Time Series Forecasting in Python and R

Compound Poisson Processes

In this post I’ll discuss compound Poisson processes, which I read about in the final chapter of Hassett and Stewart’s Probability for Risk Management last night. These model a stochastic process where at regular intervals (months, quarters, etc.) some number of events occur according to a Poisson process with rate \lambda, and the intensity of each event is determined independently by another other distribution.

Continue reading Compound Poisson Processes

Working with hdiutil

This is more of a personal note regarding the hdiutil tool.

  • To create a sparse image:
$ hdiutil create NAME -volname NAME -type SPARSE -fs hfs+j
  • To mount the drive:
$ hdiutil attach NAME.sparseimage
  • To add data to the drive:
$ mv data.txt /Volumes/NAME
  • To unmount the drive:
$ hdiutil detach /Volumes/NAME

Then, if we delete the NAME.sparseimage file, it’s gone forever and ever.