1/

Get a cup of coffee.

In this thread, I'll help you understand Markov Chains.

In life, and in investing, we often come across situations where luck/chance plays a major role.

And Markov Chains are often a great way to model and analyze such situations.

2/

Here's what prompted me to write this thread.

Earlier this week, I conducted a Twitter poll.

In the poll, I posed a question that required a bit of probabilistic reasoning.

The good news: over 10,000 people responded.

The bad news: ~87% got the answer wrong!
3/

Here's the question I asked.

Imagine we have 2 volunteers: Alice and Bob.

We give them each a fair coin.

We ask Alice to keep tossing her coin until she sees a Heads immediately followed by a Tails (ie, the pattern HT).
4/

We ask Bob to keep tossing his coin until he sees two consecutive Heads (ie, the pattern HH).

The question is: on average, who will take more tosses to get to their "target pattern" -- Alice or Bob?

Or will they both on average take the same number of tosses?
5/

More precisely:

Suppose Alice takes A tosses on average to get her HT.

And Bob takes B tosses on average to get his HH.

Then, which is the bigger number: A or B?

Or are they both the same number?
6/

We know Alice and Bob both have fair coins.

So, in any 2 consecutive tosses, Alice's HT is just as likely to show up as Bob's HH.

So, on average, it *seems* like they'll both take the same number of tosses (ie, A = B).
7/

In fact, that's exactly what ~77% of poll respondents said:

https://t.co/FAkWpX1m00
8/

But that's *not* the right answer.

The right answer is: on average, Alice's HT will appear in just 4 tosses.

But Bob's HH will take 6 tosses.

That is, A = 4 and B = 6.

Bob, on average, takes longer.

How strange!
9/

Here's the thing:

When it comes to probability, our intuition often leads us astray.

The best way to deal with it is to meticulously write down the various possible outcomes and actually work through the math.

And Markov Chains are handy models for doing just that.
10/

For example, here is Alice's Markov Chain.

It shows that, at any time, Alice can be in one of 4 possible "states" (S0 through S3).

At each state, Alice tosses her coin.

And depending on the outcome of the toss (H or T), she moves to a different state if needed.
11/

For example, S0 is the "start" state. It's where Alice starts her journey.

At S0, Alice tosses her coin.

If it comes up Heads, she follows the orange arrow from S0 (labeled "H"), which takes her to S1.
12/

At S1, Alice has seen a Heads, and is hoping for a Tails next (so she has her HT pattern).

If her toss at S1 comes up Tails, she goes to S2 -- her Win state; HT secured.

But if it comes up Heads instead, she follows the orange arrow from S1, which keeps her at S1 itself.
13/

That's all a Markov Chain is.

There's a bunch of states. At each state, a random event (like a coin toss) happens.

Based on the outcome of this random event, we follow the appropriate arrow to go to the next state.

Once at the next state, we rinse and repeat.
14/

Here's Bob's Markov Chain.

The difference between Alice and Bob is now clear.

When Bob is at S1 and gets unlucky (with a T), he has to "go back to zero" (S0) and start over.

Not so for Alice. Once Alice is at S1, she never ever has to go back to S0.
15/

That's why Bob takes longer!

From time to time, unlike Alice, Bob is forced to start from zero all over again. That's a drag.

Alice is like a drunk who either stays put or marches forward.

But Bob is like a drunk who also stumbles *backwards* on occasion.
16/

The nice thing about Markov Chains is that they allow us to quantify all this.

If we know the initial state (S0 for both Alice and Bob), we can calculate the probability of being in *any* state at *any* time.

There's a simple formula for this.
17/

This formula is "iterative".

That is, if we know the probability of being in each state at time "k" (ie, after "k" coin tosses), the formula gives us the probability of each state at the *next* time "k+1" (ie, after "k+1" coin tosses).
18/

It's quite simple.

We take the probabilities at time "k", and we pre-multiply them by a matrix (known as the Markov matrix or the Transition matrix).

This multiplication gives us the probabilities at time "k+1".

Like so:
19/

Here are the Markov matrices for Alice and Bob.

To get these matrices, we simply take the probability of each Markov Chain "arrow", and place it in the appropriate matrix slot according to the arrow's "From" and "To" states.
20/

Now, we can iterate.

Using repeated Markov matrix pre-multiplications, we get the probability of Alice and Bob being in every possible state at every possible time.

Like so (for times 0 through 4):
21/

At any time, if Alice or Bob has seen their target pattern, they'd be in S2 or S3.

So, we can see that after 4 coin tosses, Alice already has a Pr(S2) + Pr(S3) = 3/16 + 1/2 = 68.75% chance of being done.

But Bob only has a 50% chance of being done by that time.
22/

Getting the *average* time to completion is also not hard.

As "completion at, but not before, time k" is the same as "being in state S2 at time k", we have the following:
23/

So, that's the basic math of Markov Chains.

It's so simple. We move from state to state based on the outcome of chance events like coin flips.

And so powerful. Knowing just the initial state, we can exactly calculate the probability of being in *any* state at *any* time.
24/

So, what lessons can we learn from this exercise?

Key lesson 1. Probability often challenges our intuition.

That's why ~87% of FinTwit got my poll question wrong.

They relied on *intuition* rather than *math*.
25/

But chance and uncertainty are everywhere in life.

So, it's important to learn how to reason correctly about probabilistic situations -- using systematic mathematical techniques, *without* relying on our intuition.

As Charlie Munger puts it:
26/

Key lesson 2. As far as possible, we should avoid putting ourselves in situations where a single turn of bad luck could force us to start over from zero.

This was Bob's problem. That's why he took longer than Alice in our example.
27/

In investing, the equivalent is using too much leverage, naked options, trading on margin, etc.

By doing these things, we put ourselves in a position where short-term volatility and chance events could wipe us out, forcing us to essentially start from zero all over again.
28/

Key lesson 3. It's important to familiarize ourselves with "the classics" -- great ideas from multiple disciplines.

Markov Chains are not new; they date back to 1906.

But to this day, they're heavily used in various fields -- from engineering to biology.
29/

Such classic ideas that have withstood the test of time are often worthy of study.

They frequently help us think more clearly -- and thereby understand the world better.

They're good candidates for adding to our "latticework of mental models", as Charlie Munger puts it.
30/

One last thought.

Remember the game "Snakes and Ladders"?

That's a Markov Chain.

Each square on the board is a "state" we can be in. We transition between states based on random events (in this case, die rolls).

Once we know a concept, we start seeing it everywhere!
31/

Thank you very much for reading to the end of yet another long thread -- this one somewhat more mathematical than usual!

Please stay safe. Enjoy your weekend!

/End
ERROR:

In Tweet 14 above, I made a mistake in the picture showing Bob's Markov Chain.

The label on state S2 should have said "Seen HH", not "Seen HT". Corrected pic below.

Sorry about that! And many thanks to Rex Mayne (@r_mayne) for catching it and alerting me!

More from 10-K Diver

1/

Get a cup of coffee.

In this thread, I'll walk you through 2 probability concepts: Standard Deviation (SD) and Mean Absolute Deviation (MAD).

This will give you insight into Fat Tails -- which are super useful in investing and in many other fields.


2/

Recently, I watched 2 probability "mini-lectures" on YouTube by Nassim Taleb.

One ~10 min lecture covered SD and MAD. The other ~6 min lecture covered Fat Tails.

In these ~16 mins, @nntaleb shared so many useful nuggets that I had to write this thread to unpack them.

3/

For those curious, here are the YouTube links to the lectures:

SD and MAD (~10 min):
https://t.co/0TwubymdE6

Fat Tails (~6 min):

4/

The first thing to understand is the concept of a Random Variable.

In essence, a Random Variable is a number that depends on a random event.

For example, when we roll a die, we get a Random Variable -- a number from the set {1, 2, 3, 4, 5, 6}.

5/

Every Random Variable has a Probability Distribution.

This tells us all the possible values the Random Variable can take, and their respective probabilities.

For example, when we roll a fair die, we get a Random Variable with this Probability Distribution:

More from All

🌺श्री गरुड़ पुराण - संक्षिप्त वर्णन🌺

हिन्दु धर्म के 18 पुराणों में से एक गरुड़ पुराण का हिन्दु धर्म में बड़ा महत्व है। गरुड़ पुराण में मृत्यु के बाद सद्गती की व्याख्या मिलती है। इस पुराण के अधिष्ठातृ देव भगवान विष्णु हैं, इसलिए ये वैष्णव पुराण है।


गरुड़ पुराण के अनुसार हमारे कर्मों का फल हमें हमारे जीवन-काल में तो मिलता ही है परंतु मृत्यु के बाद भी अच्छे बुरे कार्यों का उनके अनुसार फल मिलता है। इस कारण इस पुराण में निहित ज्ञान को प्राप्त करने के लिए घर के किसी सदस्य की मृत्यु के बाद का समय निर्धारित किया गया है...

..ताकि उस समय हम जीवन-मरण से जुड़े सभी सत्य जान सकें और मृत्यु के कारण बिछडने वाले सदस्य का दुख कम हो सके।
गरुड़ पुराण में विष्णु की भक्ति व अवतारों का विस्तार से उसी प्रकार वर्णन मिलता है जिस प्रकार भगवत पुराण में।आरम्भ में मनु से सृष्टि की उत्पत्ति,ध्रुव चरित्र की कथा मिलती है।


तदुपरांत सुर्य व चंद्र ग्रहों के मंत्र, शिव-पार्वती मंत्र,इन्द्र सम्बंधित मंत्र,सरस्वती मंत्र और नौ शक्तियों के बारे में विस्तार से बताया गया है।
इस पुराण में उन्नीस हज़ार श्लोक बताए जाते हैं और इसे दो भागों में कहा जाता है।
प्रथम भाग में विष्णुभक्ति और पूजा विधियों का उल्लेख है।

मृत्यु के उपरांत गरुड़ पुराण के श्रवण का प्रावधान है ।
पुराण के द्वितीय भाग में 'प्रेतकल्प' का विस्तार से वर्णन और नरकों में जीव के पड़ने का वृत्तांत मिलता है। मरने के बाद मनुष्य की क्या गति होती है, उसका किस प्रकार की योनियों में जन्म होता है, प्रेत योनि से मुक्ति के उपाय...
How can we use language supervision to learn better visual representations for robotics?

Introducing Voltron: Language-Driven Representation Learning for Robotics!

Paper: https://t.co/gIsRPtSjKz
Models: https://t.co/NOB3cpATYG
Evaluation: https://t.co/aOzQu95J8z

🧵👇(1 / 12)


Videos of humans performing everyday tasks (Something-Something-v2, Ego4D) offer a rich and diverse resource for learning representations for robotic manipulation.

Yet, an underused part of these datasets are the rich, natural language annotations accompanying each video. (2/12)

The Voltron framework offers a simple way to use language supervision to shape representation learning, building off of prior work in representations for robotics like MVP (
https://t.co/Pb0mk9hb4i) and R3M (https://t.co/o2Fkc3fP0e).

The secret is *balance* (3/12)

Starting with a masked autoencoder over frames from these video clips, make a choice:

1) Condition on language and improve our ability to reconstruct the scene.

2) Generate language given the visual representation and improve our ability to describe what's happening. (4/12)

By trading off *conditioning* and *generation* we show that we can learn 1) better representations than prior methods, and 2) explicitly shape the balance of low and high-level features captured.

Why is the ability to shape this balance important? (5/12)

You May Also Like

The chorus of this song uses the shlokas taken from Sundarkand of Ramayana.

It is a series of Sanskrit shlokas recited by Jambavant to Hanuman to remind Him of his true potential.

1. धीवर प्रसार शौर्य भरा: The brave persevering one, your bravery is taking you forward.


2. उतसारा स्थिरा घम्भीरा: The one who is leaping higher and higher, who is firm and stable and seriously determined.

3. ुग्रामा असामा शौर्या भावा: He is strong, and without an equal in the ability/mentality to fight

4. रौद्रमा नवा भीतिर्मा: His anger will cause new fears in his foes.

5.विजिटरीपुरु धीरधारा, कलोथरा शिखरा कठोरा: This is a complex expression seen only in Indic language poetry. The poet is stating that Shivudu is experiencing the intensity of climbing a tough peak, and likening

it to the feeling in a hard battle, when you see your enemy defeated, and blood flowing like a rivulet. This is classical Veera rasa.

6.कुलकु थारथिलीथा गम्भीरा, जाया विराट वीरा: His rough body itself is like a sharp weapon (because he is determined to win). Hail this complete

hero of the world.

7.विलयगागनथाला भिकारा, गरज्जद्धरा गारा: The hero is destructive in the air/sky as well (because he can leap at an enemy from a great height). He can defeat the enemy (simply) with his fearsome roar of war.