One of the my favorite aspects of personal finance, mixed in amongst the doldrums of boring, repetitive data entry and upkeep, is future cash flow. It’s pretty much the most important thing most regular people want to know, too, right? How much money will I have [then]? When will I run out of money? And so on.
Now, I’m no authority on tools to do this kind of computation. I’ve used all of about three: a spreadsheet, Quicken, and some online Web 2.0 thingamajig. The problem with all of them is that they’re not designed flexibly enough to let you represent spending (and earning) events that don’t have really simple, discrete characteristics. That’s a fancy way of saying that about all you can do is plunk down payments and paychecks on a calendar and hope for the best. This is fine for simple questions where the [date in the future] is not too far away and everything is pretty deterministic. We all pretty much expect to get our next few paychecks, in other words.
Nay, what interests me, my friends, is being able to do more sophisticated analysis. Here are some of the types of money events I want to be able to model:
- Fixed-date transactions like all the basic tools can do.
- Recurring transactions with a fixed interval.
- Recurring transactions with a fixed interval and a variable amount. The way the amount varies should also be parameterizable, so you could have a simple constant change, a logarithmic fall-off (credit card payments against a shrinking balance look like this, roughly), or even a stepped exponential growth (paychecks with annual raises look like this).
- Recurring transactions with a varied interval and a fixed amount. One example of this is my bill from the highway ExpressToll transponder network. They only charge me $50 at a time. Once my $50 is used up, they bill for another $50. Since I don’t drive on the toll roads deterministically, the bill date varies. It should be possible to select common distribution functions (uniform, normal, and Poisson at least) for the interval. Another real-life example is purchasing replacement sets of snow tires.
- Recurring transactions with a variable amount. All manner of things from simple bills (electricity comes to mind) to freak events (hail damage - time for a new roof and an insurance deductible!) can be modeled.
- Transactions whose probability or temporal distribution is dependent upon other, previous transactions. If I get in a car accident, I’ll have to pay that right away. I might want to adjust the inputs to my annual insurance premium up a bit to account for the inevitable rate increase.

Now, some of you might be thinking the same thing as Zamba: “Dad, you’re plum crazy. How could you possibly model all of these things accurately? And, even if you could, won’t it be different in real life? And, by the way, do you have any treats?”
The truth is that this type of generic modeling tool could be useful for analyzing all manner of wealth streams, including the all-important long-term savings scenario. It’s just as easy to map various investments, investment classes, contribution scenarios, and disbursement scenarios (including your favorite guesses as to the probabilities that tax laws change, etc.) into this as day-to-day cash flow. At the end of the day we really just need the ability to Monte Carlo the transactions across time and generate a result that show average case and standard deviation. It makes it easy to approximate risk-of-ruin.
I’ve decided to implement this model in Scheme, a dialect of one of my favorite languages, LISP. Scheme is so awesome for this particular problem. It makes it very easy to take a building-block approach to constructing up more and more complicated interval calculators, distribution models, and ultimately functions that spit out these cash transactions at the desired times and for the desired amounts.
Here’s a simple example:
(define (make-every-on n d)
(lambda (x) (= (remainder (+ x 1) n) d)))
(define (make-every n) (make-every-on n 0))
Already we’ve got two functions that can help us build other functions; namely, functions that evaluate true on every nth day and functions that evaluate true on every nth day starting on the dth day. One more helper function and we’re ready:
(define (make-interval-fixed-spender amt pred?)
(lambda (day) (if (pred? day) amt 0)))
Do you pay your $10,000 mortgage payment on the 7th of each month? Well, here ya go:
(add-spender (make-interval-fixed-spender 10000 (make-every-on 30 7)))
I’ll post some fancier examples soon. I know you’ll be checking back every hour or two until then, so just remember, get up a few times an hour and stretch so as not to hurt your hands.