Back to trackLesson 6 of 25

Startup Runway 1: One Row, One Path

Uses Only Free-Tier SpiceGrinder

Problem statement

A founder has $120k in the bank. Each month the business takes in some cash and pays out more, and the net is uncertain: on average the account loses $8k a month, with a standard deviation of $12k, so a good month can even add a little. How much cash is left after a year? And how does the uncertainty grow as the months go by?

Until now a row of output has been one finished thing: one project, one claim, one release. Here a single number won’t do. What the founder lives through is a path, twelve balances in a row, each one built on the one before. So we let a row be a whole path. One row is one possible year, and since rows are independent of each other, a million rows are a million separate years.

The model

Three nodes. Normal draws one month’s net cash flow in $k. Redimension gathers twelve of those draws into one row, so a row is a year of flows. Calculate turns the twelve flows into twelve running balances: the balance after month k is 120 plus the first k flows.

  • NetFlow is Normal with mean -8 and sigma 12;
  • Year is Redimension with dimension="12": every twelve draws from NetFlow become one row of twelve columns;
  • Balance is Calculate, and writes the running balance into column k-1: y[0] = 120 + x[0], y[1] = 120 + x[0] + x[1], and so on up to y[11].
<dataset columns="balanceM1, balanceM2, balanceM3, balanceM4, balanceM5, balanceM6, balanceM7, balanceM8, balanceM9, balanceM10, balanceM11, balanceM12" seed="201">
  <root node="Balance"/>
  <nodes>
    <Normal name="NetFlow" mean="-8" sigma="12"/>
    <Redimension name="Year" dimension="12">
      <input name="NetFlow"/>
    </Redimension>
    <Calculate name="Balance" expression="y[0] = 120 + x[0]; y[1] = 120 + x[0] + x[1]; y[2] = 120 + x[0] + x[1] + x[2]; ...; y[11] = 120 + x[0] + x[1] + ... + x[11]">
      <input name="Year"/>
    </Calculate>
  </nodes>
</dataset>

The dots in expression stand for the terms left out here to keep the page readable; the file samples/simulation/cash-runway-one-path.xml has every one of the 78 terms. The output has twelve columns: column 0 is the balance after month 1, column 11 the balance after month 12.

grind --count 1000 cash-runway-one-path.xml

The first rows, with the model’s own seed, 201 (leave it alone and you get exactly these values; balances rounded to one decimal here):

122.0  105.6  79.3  66.4  36.7  16.4   7.7  20.5  28.0  10.9  -14.0  -28.6
104.0  111.1  94.7  69.0  61.1  66.9  52.5  43.1  43.6  11.4    7.2    7.3
 98.0   85.7  70.0  73.2  61.0  60.1  46.1  38.3  23.7  16.9   20.7   10.9

Read each line as a year. The first founder is unlucky: the balance falls to $7.7k in month 7, recovers a little, then goes negative in month 11 and ends the year at -$28.6k. The second ends it at $7.3k, the third at $10.9k.

A year, many times over

Two hundred gray paths of the monthly cash balance from 120 thousand dollars, fanning out over twelve months, with the mean falling in a straight red line to 24 thousand and dashed lines one standard deviation above and below it that widen steadily

The figure draws the first 200 rows of a 100,000-row run (seed 201) as 200 paths. They start together at $120k and spread out as the months pass. The mean falls in a straight line, $8k a month, to $24k at month 12. The dashed lines mark one standard deviation either side of it: $12k wide after the first month, $41.6k after the twelfth. At month 12 the 200 paths run from -$85.1k to $119.9k. Of the 200 founders, 59 end the year below zero, and 63 were below zero at some point in the year.

Two things stand out. The spread opens quickly at first and more slowly later: a funnel, not a wedge. And those last two counts differ. A founder can be below zero in the autumn and back above it by December, so the balance at the end of the year doesn’t say everything about the year. We come back to that next lesson.

How the spread grows

Why a funnel? The balance after month k is 120 plus k independent monthly flows, each with mean -8 and standard deviation 12. Means add, so the mean after k months is 120 - 8k. Variances add for independent draws, not standard deviations, so the variance after k months is k × 12² and the standard deviation is 12 √k. Twice the months do not mean twice the spread, only 1.41 times as much. The spread after four months, $24k, is twice the spread after one.

The standard deviation of the balance after each of the twelve months, measured from 100,000 rows, as dots with whiskers sitting on the curve 12 times the square root of the month, with a dashed straight line of 12 times the month rising steeply above it

Here are the measurements for months 1, 6 and 12 from the 100,000 rows (seed 201), with the standard error of each in brackets and the value the math predicts:

MonthMeanTheory 120 − 8kStandard deviationTheory 12√k
1111.997 (0.038)11212.045 (0.027)12.000
671.992 (0.093)7229.484 (0.066)29.394
1223.916 (0.132)2441.722 (0.093)41.569

The means are within one standard error of theory (the differences are 0.08, 0.08 and 0.64 standard errors). The standard deviations run a little above theory, by 1.65, 1.37 and 1.63 standard errors; the three are not independent of each other, since they come from the same 100,000 paths, and all three measurements are 0.3% to 0.4% high. That is the kind of wobble one run of this size produces, not a sign that the model is off. The other nine months behave the same way: the largest gap in a mean is 0.88 standard errors, the largest in a standard deviation 1.97. The figure above has all twelve standard deviations.

The distribution at one month

The balance at one month is not just a mean and a spread; it is a whole distribution. Each month’s balance is a sum of normal draws, so it is itself normal, which means we can say how likely any balance is.

A histogram of the 100,000 balances after month 12 with bars of 5 thousand dollars and the normal curve with mean 24 and standard deviation 41.57 drawn over it; bars below zero are red

The bars are the real balances after month 12; the black curve is the normal distribution with mean 24 and standard deviation 41.57. They agree. One consequence: the chance the balance is below zero at month 12 is the normal curve’s area to the left of zero, 28.19% (the probability that a standard normal falls below -24/41.57). Measured: 28.33% of the 100,000 rows (standard error 0.14 points), a gap of 1.0 standard errors. At month 6, where the tail is thin, it is 0.75% measured against 0.72% from the curve (1.2 standard errors).

The companion page lets you pick any month from 1 to 12 and see that month’s histogram under the normal curve, with the measured mean, spread and chance of being below zero next to the theory, and the marker on the fan of paths.

Check: do the numbers match the math?

There are two checks we can make. The first is the theory above: means at 120 − 8k, standard deviations at 12√k, the below-zero chance from the normal curve, each within about two standard errors in all twelve months.

The second is by hand, for one path. The Calculate node’s balances are just running sums, so we can redo them. Grind --node NetFlow prints the draws of the NetFlow node alone, and since every node has its own random stream, the same seed gives the same draws the model used:

grind --node NetFlow --count 36 cash-runway-one-path.xml

The first twelve numbers are path 1’s monthly flows (the next twelve are path 2’s, and so on). Adding them to the starting $120k one at a time:

Month123456789101112
Flow1.969-16.379-26.245-12.939-29.662-20.337-8.75412.8677.449-17.113-24.895-14.519
Balance by hand121.969105.59079.34566.40636.74416.4077.65320.51927.96810.855-14.039-28.559

The first row of the model’s output is 121.969, 105.590, 79.345 and so on, the same to the digits shown. Over the first three paths (36 numbers) the largest difference between the hand sums and the model’s balances, compared at full precision, is 0. This path’s twelve flows add up to -148.6, an average of -12.4 a month against the -8 expected: a bad year, about 1.3 standard deviations of the yearly total (12 × √12 ≈ 41.6) from the typical result. There is nothing in the model beyond the draws and the additions.

One practical note. The running-sum expression grows quickly: the balance after month k takes k terms, so n months take n(n+1)/2 in all, 78 for a year, 300 for two years and 666 for three. Writing it out is fine for a year but gets unwieldy for longer paths; lesson 3.1 shows how to do the same thing with a single Recur.

What this gives you: a way to turn a process over time into a single row (draw one step at a time, gather the steps with Redimension, then accumulate with Calculate); the habit of reading the fan of paths as well as the end value; and the rule that independent steps make the spread grow as the square root of time, which the measured standard deviations followed at every month.

So far we have asked where the balance stands at month 12, or at any single month. But a founder doesn’t live in the average. A founder with $5k at the end of the year may have been at -$30k in August, and a company that touches zero has a problem even if it recovers. Of the 100,000 rows, 28.3% end the year below zero, but 30.1% are below zero at some point in the year, one row in every 56 or so dipping under and climbing back out. The end balance hides the risk that matters. The next lesson asks about the lowest point of the path: how low does the cash go, and how often does it run out?