1/

Get a cup of coffee.

In this thread, I'll help you understand Generating Functions.

They're a super cool math technique you can use to predict the behavior of various financial models. Using just pencil and paper. No Excel!
2/

Imagine we have a portfolio that returns 10% per year.

And we save $50K per year -- which we add to this portfolio.

So, each year, the portfolio grows 10% via compounding, plus $50K of new money pours in.

Starting at $0, what will our portfolio be worth after 30 years?
3/

Many models in finance and investing follow a pattern like this.

They connect the previous year to the next year using a simple formula.

For our example, the formula is: compound the previous year's portfolio by 10% and add $50K => that gives us the next year's portfolio.
4/

We can model this using a Recurrence Equation.

Let W(N) be the portfolio's value after N years.

Then, the Recurrence Equation lets us calculate W(N) from W(N - 1).

Like so:
5/

Generating Functions are a powerful way to solve such Recurrence Equations.

And such Recurrence Equations are at the heart of all kinds of financial models.

So, Generating Functions are a super useful trick to keep in our toolbox.
6/

This is a 3-part trick.

Part 1: Define a "polynomial series" f(x) whose coefficients are the things we want to calculate.

For example, we want to calculate W(N) -- our portfolio's value after N years.

So, we'll let W(0), W(1), W(2), ... be our coefficients.

Like so:
7/

This f(x) is our "Generating Function".

Part 2: Apply the Recurrence Equation to the Generating Function, and simplify until a formula for f(x) emerges.

Brace yourself, this is going to get mathy!
8/

So, after all that math, we end up with a formula for our Generating Function f(x).

Now for the final part.

Part 3: Write the f(x) formula as a new polynomial series. The coefficients of this series are of course the very things we originally set out to calculate!
9/

Our final W(k) equation above tells us *exactly* what our portfolio will be worth after 30 -- or any other number of -- years.

It's about $8.2M after 30 years.

See? Just paper and pencil.

OK, a calculator too.

But no simulation. No Excel. No Python. Just math.
10/

Another example: What's the monthly payment on a $500K 30-year 3% fixed rate mortgage?

Here's the Generating Function solution:
11/

This tells us that our monthly mortgage payment will be ~$2,108.02.

With the help of Generating Functions, we worked it out using just paper and pencil.

And hey! Google's mortgage calculator agrees with us:
12/

Let's do a third example!

Many investors use "cohort analysis" to model the unit economics of businesses. For example, Life Time Value (LTV) vs Customer Acquisition Cost (CAC) trade-offs.

Generating Functions can give us useful insights into such models.
13/

For example, suppose it costs a company $100 to acquire a customer.

That is, CAC is $100 per customer.

And once a customer signs up, the company makes $50 off them in their first year and $75 off them in all future years.
14/

Also, churn among first year customers is high. Only 50% of them continue into Year 2.

But from Year 2 onwards, customer retention rates are high -- say, 90%.

That is, 90% of Year 2 customers sign up for Year 3, 90% of Year 3 customers sign up for Year 4, etc.
15/

Suppose the company starts with $100K of capital -- all of which is used to acquire customers.

And suppose the company re-invests all its earnings each year to acquire even more customers.

How will the number of customers scale over time?
16/

This is basic cohort analysis.

We have 2 customer cohorts: "Year 1" and "Year 2+". They have different income and churn characteristics.
17/

Cohort analysis of this sort can be boiled down to a Recurrence Equation.

The more cohorts we have, the more terms in the equation.

For example, we have 2 cohorts. So, our equation connects the current year to 2 previous years.

Like a Fibonacci series:
18/

As usual, we use Generating Functions to solve our cohort Recurrence Equation.

This gives us exact formulas for the number of customers in each cohort, the income from them, etc., over time.

Surprisingly, the square root of 166 plays a big role!
19/

The Generating Function also gives us key insights into the long run behavior of our cohorts.

For example, the 1.3442^(k-1) tells us that the number of customers in each cohort, the income from them, etc., will compound at ~34.42%. The 0.0558^(k-1) will quickly die down.
20/

So, that's the crux of our Generating Function method.

We, a) define a Generating Function, b) apply our Recurrence Equation to it, and c) write the result as a new series whose coefficients solve the problem we're interested in.
21/

And the beauty is that the same procedure solves a wide variety of Recurrence Equations.

This gives the method broad applicability in finance and investing -- with uses ranging from calculating mortgages to analyzing cohorts.
22/

To learn more, I recommend the book Generatingfunctionology by Herbert Wilf.

The first sentence of this book: A Generating Function is a clothesline on which we hang up a sequence of numbers for display.

What a beautiful way to put it!

Amazon link: amazon.com/generatingfunc…
23/

I'll leave you with a question to ponder.

In our first example above, our portfolio compounded at 10%, and we added $50K to it each year.

But what if our savings don't remain flat at $50K?

Suppose they *start* at $50K in Year 1, but then *grow* at 5% per year thereafter.
24/

In that case, what will the Recurrence Equation look like?

And the Generating Function?

And the formula for the portfolio's worth after N years? In particular, after 30 years?

See if you can solve it! Leave a comment if you do.

(I'll post a solution later this week).
25/

Hammer in hand, everything looks like a nail.

Recurrence Equation in hand, everything looks like a Generating Function.

I hope this thread showed you a new and interesting way to analyze financial models.

Thank you very much. Stay safe. Enjoy your weekend!

/End

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with 10-K Diver

10-K Diver Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @10kdiver

7 Aug
1/

Get a cup of coffee.

In this thread, I'll show you how the P/E ratio of a portfolio is related to the P/E ratios of its individual stocks.

The math here is beautiful. It involves harmonic means and a super elegant theorem known as the Cauchy-Schwarz Inequality.
2/

Earlier this week, I conducted a poll where I asked this question about P/E ratios.

Over 6,000 people responded.

Unfortunately, most of them got the answer wrong.

That's why I'm writing this thread. To (hopefully) correct some of the misconceptions that led people astray.
3/

To answer questions like this, it's always a good idea to go back to first principles.

In this case, we should ask ourselves: what exactly does a P/E ratio capture?
Read 28 tweets
1 Aug
1/

Get a cup of coffee.

In this thread, I'll walk you through the importance of thinking multi-dimensionally.

This is an essential skill for investors. It helps us make better decisions in situations that involve non-linear combinations of several key factors.
2/

Recently, I conducted a poll on Twitter.

In the poll, I posed the following question about "chains of kindness" at Starbucks.

(Please read the question, as you'll need it to get through the rest of the thread.)
3/

Answering this question correctly requires non-linear multi-dimensional thinking.

The responses that the poll received suggested that people were having difficulty with this.

That's why I'm writing this thread.
Read 28 tweets
11 Jul
1/

Get a cup of coffee.

In this thread, I'll show you how to count the number of oranges in a pile.

Believe it or not, this exercise can teach us a few lessons about investing.
2/

Earlier this week, I conducted a poll, where I asked the following question:

Here's a pile of oranges, of height 4. The pile contains 20 oranges.

Along the same lines, suppose we build a bigger pile -- of height 100. How many oranges will this bigger pile contain?
3/

The right answer is 171,700. That's how many oranges there'll be in a (similarly constructed) pile of height 100.

The right answer did receive the most votes. Yay!

But a *majority* of respondents (~66.3%) got the answer wrong.

Note: *Plurality* does not mean *majority*!
Read 34 tweets
4 Jul
1/

Get a cup of coffee.

In this thread, I'll walk you through the key differences between *earnings* and *cash flows*.

The punch line: Just because a company reports $1 of *earnings*, it does NOT mean the company has $1 more *cash* to distribute to owners.
2/

Before we look at a company's *earnings*, it's useful to understand the concept of Net Worth.

Net Worth (also called Book Value, or Shareholder's Equity) is simply the difference between what a company *owns* (ie, its assets) and what it *owes* (ie, its liabilities).
3/

Companies typically *own* a bunch of assets.

These include cash, "accounts receivable" (ie, money owed to the company by customers), "inventory" (ie, raw materials and finished products), "property, plant, and equipment" (ie, land, buildings, and factories), etc.
Read 37 tweets
27 Jun
1/

Get a cup of coffee.

In this thread, I'll walk you through the benefits of turning capital quickly.

The math behind turning capital is beautiful. It leads us to the number "e", which plays a vital role in so many different fields -- from astrophysics to biology.
2/

Imagine we have $1M.

Also, we know an extraordinarily generous bank where we can deposit this $1M.

This bank will pay us interest. And not a paltry 1% or 2%, but a hefty *100%* per year!

(I know, I know. But humor me, will you?)
3/

So, if we deposit our $1M at this bank, it will earn that 100% interest and become $2M in 1 years' time.

But that's *only* if the interest is *compounded annually*.
Read 25 tweets
20 Jun
1/

Get a cup of coffee.

Let's talk about dividends.

From an investor's standpoint, dividends are key determinants of "intrinsic value".

From a company's standpoint, dividends are key capital allocation tools.

This thread will help you appreciate *both* these perspectives.
2/

Let's do a thought experiment.

Suppose a rich uncle gives us $1M.

We're allowed to invest this $1M for our own benefit.

But there are 2 conditions:

1. Within a week, we must put the entire $1M into a *single* stock. And,

2. We can *never* sell any shares.
3/

This is a "buy and hold forever" scenario.

Whichever stock we choose, we must buy $1M worth of its shares within a week.

And after that, there are no more decisions.

We must simply hold our shares *forever*.

The question is: how do we decide which stock to buy?
Read 43 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(