Monthly Archives: June 2014

Life Tips- Watch Pixar Movies

pixar

Maria and I are of the opinion that they (Hollywood) don’t make movies for us anymore. We dislike the vast majority of adult movies. Most of them turn out to be vulgar, overly violent, pornographic, full of bathroom humor, or lousy sequels.

My suggestion is to watch animated movies, particularly those by Pixar. While they’re made for children, they’re full of jokes for adults. There are some silly childish gag scenes, but for the most part, I’m really impressed by the movies. They’re really funny and sometimes quite emotional.

Or perhaps I’m just seven years old.

Code Monkey Monday- Setting Up Self-Version Control

I program a lot. Mostly by myself. Sometimes at the office and sometimes at home. Last week, I suggested you set up Dropbox to store your personal files as you move from home to work. This week, I’ll show my solution to version control on these programming files.

While I do program by myself most of the time, version control keeps me from being an idiot and messing up my projects. It saves versions every time I “check in” my code and allows me to revert to a previous version if something goes wrong. I learned version control with Subversion, so I will be using that here. I know Git and Mercurial are also popular, so you may want to check out those instead.

I downloaded Subversion to both my work computer and personal laptop. This allows me to check in files from Windows Explorer by right-clicking on them. But first, we must set up a repository. Go into your Dropbox folder and create a folder titled “Repo”. Right-click this new folder and click TortoiseSVN->Create Repository Here.

Also in Dropbox, you are going to check out your code twice. Once from your personal computer and once from your work computer. I will explain why we check out two sets of the code in a couple paragraphs. Create a folder in Dropbox called “Repo-Checked out from home” (or work if you’re at work). Right-click on this folder and select SVNCheckout. The URL of your repository will be something like “file:///C:/Users/computerName/Dropbox/Repo”. Do a Fully Recursive checkout from the HEAD revision. Do the same thing at both work and home, adjusting the last word of the folder name accordingly.

This will set up your checked out code folders to have sub-folders “branches”, “tags”, and “trunk”. I’m working by myself, so I store all my code in the “trunk” sub-folder. Create a folder in “trunk” for each project and store your code in there. When you want to check in, right-click on the project folder and select “SVN Commit”. This will send your code to the Repo. When you next change computers, you’ll need to right click on the “Repo-Checked out from home/work” folder of your location and select “SVN Update”. This will update the files in this other repository with your work from the other location. Always update/commit from the correct folder on the correct computer.

I use two repositories like this because I use a development environment (Eclipse) that makes you select your workspace. I select one of the checked out code folders for home and one for work. If I ever lock my computer with Eclipse still running, I cannot select that same folder to be my workspace in Eclipse from another computer. So I can’t have both computers using the same checked out code folder as workspace if I plan on ever leaving Eclipse open when I travel. Having two folders, one for work and one for home, gets around this issue.

Book Review- The Midwest: God’s Gift to Planet Earth

The Midwest: God’s Gift to Planet Earth
By The Employees of Raygun, LLC, 2012

the midwest god's gift

Possibly the greatest book ever written. To be honest, there are so many great things about the Midwest in this book that I had to take a year-long break to recuperate in the middle of reading it.

The Midwest spans from Ohio in the east to Kansas and the Dakotas in the west. The area anchors this country and is home to most of the major developments of the last 150 years.

Let’s focus on just one state: Ohio, where I lived for 22 years. Birthplace of aviation (the Wright brothers, John Glenn, Neil Armstrong). Mother of presidents. The dominant swing state in the country, having voted for the winning presidential candidate every election since 1964. Site of America’s great naval beat-down of Canada: “We have met the enemy and they are ours”. A state so dedicated to technological progress that it is willing to pollute a river so much that it repeatedly catches on fire. Host of the country’s best amusement park and biggest college. Modern home of Victoria’s Secret, Wendy’s, Macy’s, Proctor and Gamble, and Hustler. And that’s just one of the Midwest’s states. Each of the others has their own awesome quirks.

The Midwest is so damn nice. The people are friendly, often comically so. The weather is fair and balanced, at least in Ohio and Indiana. Big cities are available, but so are tons of beautiful, open spaces. Chock full of history and promising an impressive future.

While this tome is a tour de force of Midwestern awesomeness, the most interesting part may have been the comparison to China. China is a burgeoning economic power that seems to create the vast majority of the world’s products. “One example of China’s dominance is Foxconn, the Chinese factory that turns out 40% of the world’s smart phones from a facility that employs somewhere between 200,000 and 400,000. The scale seems staggering, but in proportional terms, Foxconn is still one quarter the size of Henry Ford’s River Rouge plant in 1930.” China is where the Midwest was 100 years ago. We were an industrial giant— cars, planes, industrial equipment— at the same time that we were innovating farming and politics. The Midwest created more World War II material— guns, munitions, food— than the rest of the world combined. The Midwest had to deal with the spoils of prosperity: environmental damage and pollution, corruption, income inequity, slums and crime, the decline of local craftsmen. While China may be the manufacturing sweetheart for all the products that we design today, it too will have to overcome major growing pains in the future. Staggering pollution. Labor unrest due to a populace growing smarter and wealthier. If China is lucky, it will follow the Midwest’s guide to handling success.

Amazon Link: The Midwest God’s Gift to Planet Earth

Theory Thursday- Simulation of a Poisson Process

You are using discrete-event simulation to analyze a process or system. Imagine that your arrivals occur according to a Poisson Process. Without using specialized simulation software, this post shows how to code up a Poisson arrival process. Y_n will represent the n’th arrival time.

Stationary arrivals:
If your arrival rate does not vary over time, then your task is easy. You have two main options:
1. Generate exponential random variables X_1, X_2, … , representing interarrival times. Set Y_1 = X_1, Y_2 = Y_1+X_2, Y_3=Y_2+X_3,… Stop generating random variables when Y_m>T for some m, where T is your time interval length that you want to simulate.
2. Generate a Poisson random variable N(T), representing the number of arrivals over a time interval of length T. Then generate N(T) uniform [0,T] random variables, representing arrival times. Sort the arrival times in ascending order to obtain Y_1, Y_2, …

Non-stationary arrivals:
If your arrival rate varies over time, you’ll need an extra step or two of logic to generate your arrival times. Here are two options for simulation:
1. Find the highest arrival rate in your time interval, \lambda_{max}. Generate a stationary Poisson process with rate \lambda_{max} as in option 1 in the stationary arrival section above. For each arrival simulated, generate a uniform[0,1] random variable. If this uniform random variable is less than \lambda(t)/\lambda_{max}, where \lambda(t) is the arrival rate at the generated arrival time, accept the arrival as “real” and keep it. If not, discard the arrival. The “real” arrivals make up an accurate non-stationary Poisson arrival process.
2. Divide the time period [0,T] into small time increments. For each time increment, generate a uniform[0,1] random variable. For each time increment, if the uniform variable is less than or equal to \lambda(t) dt, where dt is the time increment size, then an arrival occurs during that increment. Assign the arrival time to be a random time in the increment. This method is only approximately correct, but it is good enough in most cases and may be faster to simulate in certain cases.

There are other options, but these will get you started in simulating your Poisson processes.

Betting on Underdogs in the NFL

I recently read the paper “Herd behaviour and underdogs in the NFL” by Sean Wever and David Aadland. It describes the phenomenon whereby bettors overvalue favorites in the NFL. They speculate briefly that this is due to the media and analysts over-hyping certain popular teams and under-estimating the parity that exists in the NFL. They create a model that suggests that betting on certain longshot underdogs will result in a positive expected betting profit. Because you typically wager $110 to win $100 when betting against the spread, you have to win more than 52.38% of the time to make money.

They fit their model on data from 1985-1999, and the model recommended betting on home underdogs when the spread was +6.5 or more and away underdogs when the spread was -10.5 or less. If they had used this betting strategy from 2000-2010, they would have made 427 bets, of which 246 would have won. That’s a winning percentage of 57.61%. If they bet $110 on each of those 427 games, they would have made $4690 over the 10 years, thus returning about $11 profit on each $110 bet. That’s a 10% return on investment, if I’m not mistaken. Pretty impressive.

sports_betting_logo

Sacramento Kings Crowdsource Draft Analytics

Painfully interesting mini-movie from Grantland about the Kings’ GM crowdsourcing some of their draft analytics to get fresh ideas.

It’s a deep draft. But with my minimal analysis, I don’t seem a huge difference in player potential from the ~4-~20 range. The Kings have the 8 pick, right in the middle of the “really good, but not necessarily great” range. If they can identify some value picks toward the end of the lottery or the late first round, I think it makes sense to move down from the 8 spot if they can get 2 first round picks in return. But I doubt anyone will offer that. Looking forward to seeing what happens in the draft.

Theory Tuesday- Queueing Notation

When people describe queues in queueing theory, they use a certain notation that at first looks cryptic. For example, a queue that has exponential interarrival times, exponential service times, one server, and room for 10 people in the queue is denoted as an M/M/1/10 queue.

What do the letters in queueing notation mean?

The first letter specifies the probability distribution of interarrival times.
The second letter specifies the probability distribution of service times.
The third letter represents the number of servers working in parallel in the queue.
The fourth letter represents the maximum number of customers in the queue. If omitted, it is assumed to be infinite.

Here are the most common options for the first two letters:
M = exponential (Markovian) distribution
D = deterministic arrival/service times
E_n = gamma distribution with shape parameter n (also called an Erlangian distribution)
G = general distribution (most everything else)

Code Monkey Monday- Dropbox for moving files between home and work

I got frustrated by the unreliability of IU’s shared drive in the fall. I also got tired of forgetting files at home or work when I needed them at the other location. So I took the plunge and set up a Dropbox account. I can now store all of my files on Dropbox and not worry about bringing them with me everytime I go home. I downloaded the desktop application to my work computer and personal laptop, which automatically synchs any updates and keeps me from having to go to dropbox.com every time I want to access a file. This works well for personal and homework files; I doubt it would be advisable for anything proprietary or confidential.

Next week, I’ll show how I set up version control in my Dropbox so that I have version control on all my programming files.