10-K Diver Profile picture
Aug 14, 2021 25 tweets 8 min read Read on X
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

Jan 1, 2023
1/

Get a cup of coffee.

In this thread, I'll walk you through "Gambler's Ruin".

This is a classic exercise in probability theory.

But going beyond the math, this exercise can teach us a lot about life, business, and investing.
2/

In my mind, Gambler's Ruin is the math of "David vs Goliath" ("Skill vs Size") type situations.

Here, David is a "small" player. He only has limited resources. But he's very skilled.

Pitted against David is Goliath -- a "big" player who has MORE resources but LESS skill.
3/

The battle between David and Goliath rages on for several "rounds".

Each round has a "winner" -- either David or Goliath.

David -- because of his superior skill -- has a higher probability of winning any individual round. That's David's advantage over Goliath.
Read 32 tweets
Dec 11, 2022
1/

Get a cup of coffee.

In this thread, we'll explore the question:

As investors, how often should we check stock prices?

To answer this, we'll draw on key ideas and concepts from many different fields -- probability, information theory, psychology, etc.
2/

Imagine we have a stock: ABC, Inc.

Every day that the market is open, our stock either:

- Goes UP 1%, or
- Goes DOWN 1%.

For simplicity, let's say these are the only 2 possible outcomes on any given trading day.
3/

Suppose we think ABC is a "good" investment.

That is, the company has a wide moat, good returns on capital, decent growth prospects, etc. And the stock trades at a reasonable price.

So, we buy the stock -- expecting to make a very good return on it. Say, ~15% per year.
Read 40 tweets
Oct 23, 2022
1/

Get a cup of coffee.

In this thread, I'll walk you through 2 key portfolio diversification principles:

(i) Minimizing correlations, and
(ii) Re-balancing intelligently.

You don't need Markowitz's portfolio theory or the Kelly Criterion to understand these concepts. Image
2/

Imagine we have a stock: ABC Inc. Ticker: $ABC.

The good thing about ABC is: in 4 out of 5 years (ie, with probability 80%), the stock goes UP 30%.

But the *rest* of the time -- ie, with probability 20%, or in 1 out of 5 years -- the stock goes DOWN 50%.
3/

We have no way to predict in advance which years will be good and which will be bad.

So, let's say we just buy and hold ABC stock for a long time -- like 25 years.

The question is: what return are we most likely to get from ABC over these 25 years?
Read 23 tweets
Sep 11, 2022
1/

Get a cup of coffee.

In this thread, I'll walk you through the P/E Ratio.

Why do some companies trade at 5x earnings and others trade at 50x earnings?

When I first started investing, this was hard for me to understand.

So, let me break it down for you.
2/

Imagine we have 2 companies, A and B.

Let's say both companies will earn $1 per share next year.

And both companies will also GROW their earnings at the SAME rate: 10% per year. Every year. Forever.
3/

Suppose A trades at a (forward) P/E Ratio of 10. So, each share of A costs $10.

And B trades at a P/E Ratio of 15. So, each share of B costs $15.

Which is the better long term investment: A or B?
Read 31 tweets
Sep 4, 2022
1/

Get a cup of coffee.

In this thread, I'll walk you through a fundamental business concept that may be counter-intuitive to some of you:

Just because a business has made $1 of PROFIT, it does NOT mean the business's owners have $1 of CASH to pocket.
2/

To understand why, let's start with how PROFIT is defined.

PROFIT = SALES - COSTS

That is, we take all sales (or revenues) the company made during a quarter or year.

We back out all costs incurred during this period.

That leaves us with profits.

Seems straightforward.
3/

Here's the problem:

The way a "lay person" understands words like SALES and COSTS is completely different from the way an *accountant* uses these same words.

These discrepancies can create enormous confusion.
Read 20 tweets
Aug 28, 2022
1/

Get a cup of coffee.

In this thread, I'll walk you through a framework that I call "Lindy vs Turkey".

This is a super-useful set of ideas for investors.

Time and again, these ideas have helped me think more clearly about the LONGEVITY of the companies in my portfolio.
2/

Imagine we're buying shares in a company -- ABC Inc.

ABC is a very simple company. It earns $1 per share every year. These earnings don't grow over time.

And ABC returns all its earnings back to its owners -- by issuing a $1/share dividend at the end of each year.
3/

Suppose we buy ABC shares for $5 a share.

That's a P/E ratio of 5.

We know we get back $1/year as a dividend.

So, for us to NOT lose money, ABC should survive AT LEAST 5 more years.

If something happens and ABC DIES before then, we'll likely lose money.
Read 32 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

Don't want to be a Premium member but still want to support us?

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

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(