youtube.nixfred.com nixfred.com

The Strange Math That Predicts (Almost) Anything

Veritasium traces every modern use of Markov chains back to a bitter feud in 1905 Russia, where Pavel Nekrasov argued that convergence in social statistics was measurable proof of free will and Andrey Markov set out to destroy the argument. To do it Markov hand counted the first 20,000 letters of Pushkin's Eugene Onegin, showed the letters were plainly dependent, and built a two state chain that converged anyway. The video then follows that object through Stanislaw Ulam inventing Monte Carlo while playing solitaire in a sickbed, Brin and Page modeling the whole web as a chain to build PageRank, and Claude Shannon's word games becoming the direct ancestor of language models. It closes on where chains break, and on how many shuffles actually randomize a deck.

Published Jul 26, 2025 32:21 video 26 min read Added Nov 10, 2026 Open on YouTube →

At a glance

How many riffle shuffles does it take to randomize a deck of cards? How much uranium do you need for a bomb? How do you predict the next word in a sentence? How does Google know which page you actually wanted? Veritasium opens with those four questions and then gives one answer to all of them: a bitter mathematical feud in Russia over a hundred years ago, fought over whether statistics could prove the existence of free will.

On one side was Pavel Nekrasov, a devout Tsarist nicknamed the Tsar of probability, who argued that convergence in social statistics was measurable evidence of free will. On the other was Andrey Markov, an atheist known as Andrey the Furious, who considered the argument an abuse of mathematics and set out to demolish it. To do that he had to invent a way of doing probability on events that depend on each other, and he tested it by counting the vowels and consonants in the first 20,000 letters of Pushkin's Eugene Onegin. The thing he built to win an argument is now called a Markov chain.

The rest of the video follows that object through the twentieth century and into your pocket: the Manhattan Project mathematician who invented the Monte Carlo method while playing solitaire in a hospital bed, the two Stanford students who modeled the entire web as a chain and called it PageRank, and Claude Shannon's word games in the 1940s that are the direct ancestor of every large language model you have used. This page rebuilds the whole thing, with the numbers kept intact.

The deep explanation

1905: a political fight that infected mathematics

In 1905, socialist groups across Russia rose against the Tsar, demanding complete political reform or his abdication. The country split in two, and the split was deep enough that it reached into the mathematics faculties. Mathematicians started picking sides.

On the Tsarist side stood Pavel Nekrasov, unofficially called the Tsar of probability: a deeply religious and politically powerful man who used his standing to argue that mathematics could illuminate free will and the will of God. His intellectual nemesis was Andrey Markov, known as Andrey the Furious, an atheist with no patience for anyone he considered unrigorous. He judged Nekrasov exactly that, because in Markov's view mathematics had nothing whatsoever to say about free will or religion. He publicly attacked Nekrasov's work, filing it under the abuses of mathematics.

Their fight was not really about politics. It was about an assumption that had sat at the foundation of probability for two hundred years.

The law of large numbers, and the assumption underneath it

Flip a coin ten times and you might get six heads and four tails, nowhere near the even split you expect. Keep flipping and the ratio lurches around at first, then settles: after a hundred flips in the video's demonstration, 51 heads and 49 tails, almost exactly the expectation.

That settling is the law of large numbers: as you run more and more independent trials, the average outcome converges on the expected value. Jacob Bernoulli first proved it in 1713, and for the next two centuries it was the central pillar of probability theory.

The catch is the word independent. Bernoulli proved it for events that do not influence one another: a fair coin, or a room full of people privately writing down what they think an item is worth. Change the setup so that people shout their guesses out loud and the guarantee evaporates. The first person says two thousand dollars, everyone else is anchored by that number, and the guesses are now dependent on each other. The average no longer converges on the true value; it clusters around something higher.

So the received wisdom was: independence gets you the law of large numbers.

Nekrasov's leap: convergence therefore free will

Nekrasov accepted that. Then he reversed it, which is a very different claim. If you observe the law of large numbers, he argued, you may infer that the underlying events were independent.

He pointed at social statistics. A table of Belgian marriages from 1841 to 1845 hovers around 29,000 per year. The values look like they converge, so they look like they obey the law of large numbers. Nekrasov found the same pattern in crime rates and birth rates.

Now ask where those numbers come from. They come from decisions: to marry, to commit a crime, to have a child. If convergence implies independence, and these aggregate decisions converge, then the individual decisions behind them must be independent of one another. Independent of circumstance, independent of each other. Which is to say, in Nekrasov's reading, acts of free will.

For him this was the prize: free will stopped being a philosophical position and became something measurable. Scientific.

Markov thought this was delusional, and that linking mathematical independence to free will was absurd on its face.

Eugene Onegin, counted by hand

Refuting Nekrasov required more than contempt. Markov had to show that dependent events can also obey the law of large numbers, which would sever the inference at its root: if convergence can arise from dependence, then observing convergence tells you nothing at all about independence, and therefore nothing about free will.

He needed a system where each event obviously depended on the one before. He chose text, because whether the next letter is a vowel or a consonant depends heavily on the current letter. His corpus was the central poem of Russian literature, Alexander Pushkin's Eugene Onegin.

Markov took the first 20,000 letters, stripped out punctuation and spaces, and pushed everything into one long string. Counting by hand, he found 43 percent vowels and 57 percent consonants.

Then he broke the string into overlapping pairs, giving four combinations: vowel-vowel, consonant-consonant, vowel-consonant, consonant-vowel. If the letters were independent, a vowel-vowel pair should occur at the probability of a vowel twice over, about 0.43 squared, roughly 18 percent.

He counted the actual pairs. Vowel-vowel pairs appeared about 6 percent of the time, nowhere near 18. Every other pair was similarly far from the independent prediction. The letters were conclusively dependent.

0% 5% 10% 15% 18% if letters were independent 6% what Markov actually counted

frequency of vowel-vowel pairs in Eugene Onegin

Figure 1. The measurement that started everything. Independence predicts vowel-vowel pairs at roughly 0.43 squared. The poem delivers about a third of that, so the letters are plainly dependent on one another. Markov still had to show such a system obeys the law of large numbers.

The prediction machine

Having proved dependence, Markov needed the second half: that this dependent system still converges. So he built what the video calls a prediction machine.

He drew two circles, one for vowel and one for consonant. These are the states. From a vowel, the next letter is either a vowel or a consonant, so two arrows leave each circle. These are the transitions. The question is what numbers to put on the arrows.

He had what he needed from his counting. A random position has a 43 percent chance of being a vowel, and vowel-vowel pairs occur about 6 percent of the time. So the probability of moving from a vowel to another vowel is 0.06 divided by 0.43, about 13 percent. Since something must come next, the arrows leaving a state sum to one, so vowel to consonant is 87 percent. Repeating the arithmetic for consonants gives consonant to vowel at about 67 percent and consonant to consonant at about 33 percent.

Then you run it. Start on a vowel. Draw a random number between 0 and 1. Below 0.13 and you emit another vowel; above and you emit a consonant. The video's first draw is 0.78, so a consonant. From the consonant state the threshold is 0.67; the next draw is 0.21, so a vowel. Keep going, keeping a running tally of the vowel to consonant ratio.

At first the ratio swings wildly. Then it settles, and it settles on 43 percent vowels and 57 percent consonants: exactly the split Markov had counted by hand in the poem.

vowel 43% of letters consonant 57% of letters 87% 67% 13% 33%

Run it long enough and the ratio settles at 43 / 57: the dependent system obeys the law of large numbers.

Figure 2. The original Markov chain, with Markov's own numbers. The arrows out of any state sum to one. The transition probabilities come straight from his hand count: vowel to vowel is the pair frequency divided by the vowel frequency, 0.06 over 0.43.

Markov had built a chain of dependent events that nonetheless obeyed the law of large numbers. Convergence in social statistics therefore proves nothing about whether the underlying decisions were independent, which means it proves nothing about free will. Nekrasov's argument was gone.

Markov ended his paper with a dig at his rival: thus free will is not necessary to do probability. Independence is not necessary either.

A breakthrough nobody noticed

This should have landed hard, because almost nothing in the real world is independent. Tomorrow's weather depends on today's. How a disease spreads depends on who is infected right now. Particles behave according to the particles around them. All of it was suddenly tractable.

Instead it went largely unnoticed, and Markov himself was conspicuously uninterested in whether it was useful. The video quotes him directly:

I am concerned only with questions of pure analysis. I refer to the question of the applicability with indifference. Andrey Markov

The interview segment in the video puts it plainly: it was not a mic drop moment, people did not really notice, and the man who built it did not much care how it might apply to practical events.

Los Alamos: solitaire, neutrons, and the Monte Carlo method

On the morning of 16 July 1945 the United States detonated the Gadget, the first nuclear weapon. Six kilograms of plutonium produced a blast equivalent to nearly 25,000 tons of TNT, the culmination of three years of work by J. Robert Oppenheimer, John von Neumann, and among them a less famous mathematician named Stanislaw Ulam.

After the war Ulam kept working on how neutrons behave inside a bomb. The mechanism: a neutron strikes a uranium-235 nucleus, the nucleus splits, and the split releases energy plus two or three more neutrons. If each generation on average splits more than one further nucleus, the reaction runs away and you have a weapon. Since uranium-235 was extraordinarily difficult to obtain, the pressing question was how much of it you actually need, which is a question about neutron behavior.

In January 1946 Ulam was hit by a severe case of encephalitis that nearly killed him. Recovery was slow and he spent most of it in bed, passing time with solitaire. Game after game, one question nagged: what are the chances a randomly shuffled game of solitaire can be won?

It is a brutally hard question to answer directly. With all 52 cards, every arrangement is a different game, so the space is 52 factorial, around 8 times 10 to the 67. Analytic solution is hopeless.

Then came the insight that changed computing: do not solve it, sample it. Play hundreds of games, count the winnable ones, and take the statistical approximation.

Back at Los Alamos the same trick pointed at the neutron problem, where trillions upon trillions of neutrons interact with their surroundings and direct computation is equally impossible. Ulam proposed simulating the system by generating many random outcomes.

Von Neumann saw the power immediately and also the flaw. In solitaire each game is independent; how the cards fall in one has no effect on the next. Neutrons are not like that. A neutron's behavior depends on where it is and what it has already done. You cannot draw independent samples. You need to model a chain of events in which each step conditions the next.

What von Neumann recognized is that what they needed was a Markov chain.

The neutron chain, and the number that decides everything

The simplified version works like this. The starting state is a neutron traveling through the core. Three things can happen to it:

Unlike Markov's vowels, these transition probabilities are not fixed. They depend on the neutron's position, velocity, and energy, and on the overall configuration and mass of the uranium. A fast neutron might have a 30 percent chance to scatter, 50 percent to be absorbed or escape, and 20 percent to cause fission; a slower neutron carries different numbers entirely.

They ran the chain on ENIAC, the first electronic general purpose computer. Each run generated random starting conditions for a neutron and stepped through the chain, tracking how many neutrons were produced on average per run: the multiplication factor k. If one neutron yields two on average, k is 2; if two neutrons yield three, k is 1.5. Each full run contributes its k to a histogram, and the process repeats hundreds of times to build a distribution.

The distribution answers the question that mattered:

neutron traveling position, velocity, energy scatter absorbed or escapes this chain ends fission releases 2 or 3 neutrons each new neutron starts its own chain

k < 1 dies out · k = 1 self sustaining · k > 1 exponential

Figure 3. The chain von Neumann and Ulam ran on ENIAC. The transition probabilities move with the neutron's state and the geometry of the core, which is exactly why the problem resisted analytic solution and yielded to sampling.

Ulam and von Neumann now had a statistical route to a number nobody could calculate exactly. In effect they could approximate differential equations too hard to solve analytically. The method needed a name, and since Ulam's uncle was a gambler and the whole business of random sampling for high stakes recalled the Monte Carlo Casino in Monaco, Monte Carlo it became.

It did not stay secret long. By the end of 1948 scientists at Argonne in Chicago were using it for reactor design, and from there it spread everywhere. Ulam's own verdict:

It is still an unending source of surprise for me to see how a few scribbles on a blackboard could change the course of human affairs. Stanislaw Ulam

The web as a chain: how Google beat Yahoo

The internet opened to the public in 1993 and promptly exploded, thousands of new pages a day and accelerating. That created a new problem: finding anything at all.

In 1994 two Stanford PhD students, Jerry Yang and David Filo, founded Yahoo to address it. They needed money, so a year later they met the Japanese billionaire Masayoshi Son, sometimes called the Bill Gates of Japan, hoping to raise five million dollars.

Son offered a hundred million, twenty times what they asked. Yang declined, saying they did not need that much. Son's reply, per the video: "Jerry, everyone needs $100 million." Then, before they could respond, he asked who their biggest competitors were. Excite and Lycos, they said. Son told an associate to write the names down and added: if you do not let me invest in Yahoo, I will invest in one of them and I will kill you.

Son had worked something out. None of the leading search engines had any technological advantage; they all ranked pages by how often the search term appeared on the page. If the product was undifferentiated, the war would be won by whoever attracted the most users, which meant whoever could spend most on marketing, which meant whoever had the most money. Son had the money, so Son could choose the winner. Yahoo took the investment, and within four years became the most popular site on the planet.

But keyword ranking had a fatal weakness: it was trivially gameable. Repeat a keyword hundreds of times in white text on a white background and you rank. As one interviewee in the video puts it, there was a notion of relevance, whether a document talks about the thing you are interested in, but no notion of which results were actually better.

The missing idea came from libraries. Old library books carried a paper card stamped with every due date. A card thick with stamps meant a book worth borrowing; a blank one meant it probably was not. The stamps were endorsements.

Sergey Brin and Larry Page, also Stanford PhD students, saw that links work the same way. A link to a page is an endorsement, and the more links a page hands out, the less each of its votes is worth. Model it properly and the web becomes a Markov chain.

Take a toy internet of four pages: Amy, Ben, Chris, and Dan. The pages are the states and the links are the transitions. Amy links only to Ben, so Amy to Ben is 100 percent. Ben links to Amy, Chris, and Dan, so each gets 33 percent. Fill in the rest the same way, then set a random surfer loose: start anywhere, follow links at random, and track the share of time spent on each page. The proportions settle, and the settled values rank the pages by importance. In the video's example the surfer spends most time on Ben, then Amy, then Dan, and least on Chris.

Amy Ben Chris Dan

100%

33% each

settled time share 1. Ben 2. Amy 3. Dan 4. Chris

85% of the time follow a link, 15% of the time jump to a random page, so the surfer never gets trapped.

Figure 4. PageRank as a Markov chain. The ranking is the stationary distribution of a random surfer, which is why a link farm fails: a hundred pages pointing at you look important for a few steps, but since nothing reputable points at them, their contribution washes out over many steps.

Two refinements make it work on the real web. First, the link farm attack fails on its own: build a hundred pages that all point at you and they may look important for the first few steps, but nothing else links to them, so over many steps their contribution vanishes. Many links is not the same as quality links. Second, not all pages are connected, and a random surfer can get stuck in a loop that never reaches the rest of the web. The fix is a damping factor: 85 percent of the time follow a link normally, 15 percent of the time jump to a page at random. That guarantees the whole web gets explored.

They called it PageRank, partly because it ranks pages and partly, as the video notes with amusement, because Larry Page snuck his own name in.

The results were dramatically better, often landing you on the right site in one go. Not everyone considered that a selling point. One contemporary objection quoted in the video: if it takes three or four searches to get the right answer, that is three or four chances to show ads, so better search is worse business.

Brin and Page disagreed, betting that a far superior product would win anyway. Page's framing, in the video:

I would say it actually is a democracy that works. If all pages were equal, anybody can manufacture as many pages as they want. I can set up a billion pages on my server tomorrow. We shouldn't treat them all as equal. Larry Page

They launched in 1998 under the name BackRub, after the backlinks it analyzed, then concluded that was not the most attractive brand. Wanting a name as large as their ambition of indexing the entire web, they reached for the largest number they could think of, 10 to the power 100, a googol. Registering the domain, they misspelled it. Google was born, overtook Yahoo within four years, and Alphabet is now worth around two trillion dollars.

Shannon, tokens, and the straight line to language models

At the heart of that trillion dollar algorithm is a Markov chain: a process that looks only at the current state to predict the next.

In the 1940s Claude Shannon, the father of information theory, returned to Markov's original idea of predicting text and pushed it. Instead of vowels and consonants he used individual letters, and instead of conditioning on the last letter alone he asked what happens if you condition on the last two. The output is gibberish with recognizable fragments embedded in it, words like "way of off and the."

Convinced he could do better, he moved from letters to whole words as predictors, which produced sentences like: "The head and in frontal attack on an English writer that the character of this point is therefore another method for the letters that the time of whoever told the problem for an unexpected."

Clearly nonsense overall. But Shannon noticed that runs of about four words do make sense. "Attack on an English writer" is fine. The lesson generalizes: condition on more of the preceding text and your predictions of the next word get better and better.

That is the same machinery behind Gmail finishing your sentence, and the video is explicit that this is no coincidence. The modern version swaps letters for tokens, as the expert in the video explains: not necessarily letters, but a larger set including words, word pieces, and punctuation. The game is unchanged. Given a string of tokens, perhaps thirty long, what are the odds the next token is this one or that one.

What separates a large language model from a plain Markov chain is that it does not treat all those tokens equally. It uses attention, which tells the model what to weigh. In the phrase "the structure of the cell," surrounding context like blood and mitochondria tells the model that cell means biology rather than a prison, and it tunes the prediction accordingly.

Where the chain breaks

The video closes honestly, with two cases where this machinery fails.

The first is model collapse. As language models proliferate, their output lands on the internet and becomes training data for the next generation. The expert's verdict is blunt: once you start doing that the game is very soon over, and you arrive at a very dull stable state that says the same thing over and over forever. Language models are vulnerable to this.

The second is feedback loops generally. Take global warming: more carbon dioxide raises average temperature, a warmer atmosphere holds more water vapor, water vapor is itself a powerful greenhouse gas, so the temperature rises further and the atmosphere holds more still. A system that feeds back into itself like that is hard to model as a Markov chain.

So there are systems where chains do not work. For an enormous number of other dependent systems, they are the way probability gets done.

The idea underneath all of it

The through line is one property. Every system here has an immensely long history. You could trace every letter that came before in a text, every interaction a neutron has had, weeks of prior weather. The discovery is that for many systems you can throw nearly all of it away and look only at the current state. That is the memoryless property, and it is the whole source of the power: it collapses impossibly complex systems into something simple enough to compute while still making meaningful predictions.

As one paper quoted in the video puts it, problem solving is often a matter of cooking up an appropriate Markov chain.

And the origin of all of it stays faintly absurd, which the video lets an interviewee say out loud: it is ridiculous that this basic fact of mathematics came out of a fight that had nothing to do with it, yet the evidence suggests it really was Markov's determination to show Nekrasov up that drove him to the work.

The card question, answered

Back to the opening question: how many shuffles randomize a deck? The street interviews produce guesses of two, four, seven, twenty six, fifty two.

Seven is right. Treat card shuffling as a Markov chain where each arrangement of the deck is a state and each shuffle is a step. For 52 cards, seven riffle shuffles leaves every arrangement roughly equally likely, which is effectively random.

That holds for a proper riffle. For the overhand shuffle, the sort where you peel cards off in clumps, the answer is over two thousand. So when someone offers to shuffle before a game, the video's advice is to check how: seven riffles or it does not count.

WhereThe statesThe transitionsThe question it answered
Markov, 1913Vowel, consonantCounted pair frequencies in Eugene OneginCan dependent events obey the law of large numbers? Yes, so convergence proves nothing about free will
Los Alamos, 1946Neutron traveling, absorbed or escaped, fissionVary with position, velocity, energy, core geometryHow much uranium makes k exceed 1
PageRank, 1998Web pagesLinks, split evenly, plus a 15% random jumpWhich page is actually worth returning first
Shannon to LLMsLetters, then words, now tokensLearned from a corpus, weighted by attentionWhat is the next token
Card shufflingEvery arrangement of the deckOne shuffleSeven riffles randomizes 52 cards; over 2,000 overhand
Where it failsSystems that feed back on themselvesOutputs re-enter as inputsModel collapse and climate feedback resist the memoryless assumption

Key takeaways

Chapters

Notable quotes

Thus free will is not necessary to do probability. Andrey Markov, closing his paper against Nekrasov, 8:16

I am concerned only with questions of pure analysis. I refer to the question of the applicability with indifference. Andrey Markov, on whether his chains were useful, 9:35

It is still an unending source of surprise for me to see how a few scribbles on a blackboard could change the course of human affairs. Stanislaw Ulam, 16:09

Jerry, everyone needs $100 million. Masayoshi Son to Jerry Yang, 17:28

If you don't let me invest in Yahoo, I will invest in one of them and I'll kill you. Masayoshi Son, naming Excite and Lycos, 17:53

You're telling me you get a search that will get the right result on the first answer? I don't want that, because if it takes them three or four searches to get the right answer, then I have three or four chances to show ads. A contemporary objection to better search, 23:08

I would say it actually is a democracy that works. If all pages were equal, anybody can manufacture as many pages as they want. Larry Page, 23:34

When you start doing that, the game is very soon over. You come in this case to a very dull stable state. It just says the same thing over and over and over again forever. On models trained on model output, 27:30

Problem solving is often a matter of cooking up an appropriate Markov chain. Quoted in the video, 29:16

Resources mentioned

Full transcript
[0:00] How many times do you need to shuffle a deck of cards to make them truly random? How much uranium does it take to build a nuclear bomb? How can you predict the next word in a sentence? And how does Google know which page you're actually searching for? Well, the reason we know the answer to all of these questions is because of a strange math feud in Russia that took place over a hundred years ago. [0:26] In 1905, socialist groups all across Russia rose up against Thesar, the ruler of the empire. They demanded a complete political reform or failing that that he step down from power entirely. This divided the nation into two. So on one side you got the Tsarists, right? They wanted to defend the status quo and keep the tsar in power. But then on the other side you had the socialists who wanted this complete political reform. [0:53] And this division was so bad that it crept into every part of society to the point where even mathematicians started picking sides. On the side of the zar was Pavl Necrosov unofficially called the zsar of probability. Necrasov was a deeply religious and powerful man and he used his status to argue that math could be used to explain free will and the will of God. His intellectual nemesis on [1:18] the socialist side was Andre Marov, also known as Andre the Furious. Marov was an atheist and he had no patience for people who were being unrigorous, something he considered Necrosoft to be because in his eyes, math had nothing to do with free will or religion. So he publicly criticized Necrosoft's work, listing it among the abuses of mathematics. Their feud centered on the main idea people had [1:43] used to do probability for the last 200 years. And we can illustrate this with a simple coin flip. When I flip the coin 10 times, I get six times heads and four times tails, which is obviously not the 50/50 you'd expect. But if I keep flipping the coin, then at first the ratio jumps all over the place. But after a large number of flips, we see that it slowly settles down and approaches 50/50. And in this case, after 100 flips, we [2:10] end up on 51 heads and 49 tails, which is almost exactly what you would expect. This behavior that the average outcome gets closer and closer to the expected value as you run more and more independent trials is known as the law of large numbers. It was first proven by Jacob Bernoli in 1713, and it was the key concept at the heart of probability theory right up until Marov Necrosov. [2:36] But Berni only proved that it worked for independent events like a fair coin flip or when you ask people to guess how much they think an item is worth where one event doesn't influence the others. But now imagine that instead of asking each person to submit their guess individually, you ask people to shout out their answer in public. Well, in this case, the first person might think it's an extraordinarily valuable item [3:02] and say it's worth around $2,000. But now all the other people in the room are influenced by this value and so their guesses have become dependent. And now the average doesn't converge to the true value but instead it clusters around a higher amount. And so for 200 years probability had relied on this key assumption that you need independence to observe the law of large numbers. And [3:28] this was the idea that sparked Necrosov and Marov's feud. See, Necrosov agreed with Bernoli that you need independence to get the law of large numbers. But he took it one step further. He said, "If you see the law of large numbers, you can infer that the underlying events must be independent." Take this table of Belgian marriages from 1841 to 1845. Now, you see that every year the average [3:54] is about 29,000. And so, it seems like the values converge and therefore that they follow the law of large numbers. And when Microsoft looked at other social statistics like crime rates and birth rates, he noticed a similar pattern. But now think about where all this data is coming from. It's coming from decisions to get married, decisions to commit crimes, and decisions to have babies, at least for the most part. So Necrosoft reasoned that because these [4:19] statistics follow the law of large numbers, the decisions causing them must be independent. In other words, he argued that they must be acts of free will. So to him, free will wasn't just something philosophical. It was something you could measure. It was scientific. But to Marov, Necrosov was delusional. He thought it was absurd to link mathematical independence to free will. [4:45] So Marov set out to prove that dependent events could also follow the law of large numbers and that you can still do probability with dependent events. To do this, he needed something where one event clearly depended on what came before. And he got the idea that this is what happens in text. Whether your next letter is a consonant or a vow depends heavily on what the current letter is. So to test this, Marov turned to a poem [5:13] at the heart of Russian literature. Eugene Anigan by Alexander Pushkin. He took the first 20,000 letters of the poem, stripped out all punctuation and spaces, and pushed them together into one long string of characters. He counted the letters and found that 43% were vowels and 57% were consonants. Then Marov broke the string into overlapping pairs. That gave him four [5:38] possible combinations. Vow, vowel, consonant, consonant, vow, consonant, or consonant vowel. Now if the letters were independent the probability of a vow vow pair would just be the probability of a vow twice which is about.18 or an 18% chance. But when Marov actually counted he found valval pairs only show up 6% of the time way less than if they were independent. [6:06] And when he checked the other pairs he found that all actual values differed greatly from what the independent case would predict. So Marov had shown that the letters were dependent. And to beat Necrosov, all he needed to do now was show that these letters still follow the law of large numbers. So he created a prediction machine of sorts. He started by drawing two circles, one for a vowel and one for a consonant. [6:32] These were his states. Now, say you're at a vowel, then the next letter could either be a vowel or a consonant. So he drew two arrows to represent these transitions. But what are these transition probabilities? Well, Marov knew that if you pick a random starting point, there is a 43% chance that it'll be a vowel. He also knew that val pairs occur about 6% of the time. So to find the [6:57] probability of going from a vowel to another vowel, he divided 06 by43 to find a transition probability of about 13%. And since there is a 100% chance that another letter comes next, all the arrows going from the same state need to add up to one. So the chance of going to a consonant is 1 minus.13 or 87%. He repeated this process for the [7:23] consonants to complete his predictive machine. So let's see how it works. We'll start at a vowel. Next, we generate a random number between 0 and 1. If it's below.13, we get another vowel. If it's above, we get a consonant. We got 78, so we get a consonant. Then we generate another number and check if it's above or below 67.21, so we get a vowel. Now, we can keep [7:50] doing this and keep track of the ratio of vowels to consonants. At first, the ratio jumps all over the place, but after a while, it converges to a steady value. 43% vowels and 57% consonants. The exact split Marov had counted by hand. So Marov had built a dependent system, a literal chain of events. And he showed that it still followed the law of large [8:16] numbers, which meant that observing convergence in social statistics didn't prove that the underlying decisions were independent. In other words, those statistics don't prove free will at all. Marov had shattered Necrosov's argument and he knew it. So he ended his paper with one final dig at his rival. Thus free will is not necessary to do probability. In fact independence isn't even necessary to do probability with [8:43] this marov chain as it came to be known. He found a way to do probability with dependent events. This should have been a huge breakthrough because in the real world almost everything is dependent on something else. I mean, the weather tomorrow depends on the conditions today. How a disease spreads depends on who's infected right now. And the behavior of particles depends on the behavior of particles around them. Many [9:09] of these processes could be modeled using Marov chains. Do people think it was like a mic drop moment like oh Necrosov is out like Marov's a man or people didn't really notice or it was obscure or I I feel like people didn't really notice like it wasn't a really big thing and Mark of himself seemingly didn't care much about how it might be applied to practical events. He wrote I am [9:35] concerned only with questions of pure analysis. I refer to the question of the applicability with indifference. Little did he know that this new form of probability theory would soon play a major role in one of the most important developments of the 20th century. On the morning of the 16th of July 1945, the United States detonated the gadgets, [10:01] the world's first nuclear bomb. The 6 kg plutonium bomb created an explosion that was equivalent to nearly 25,000 tons of TNT. This was the culmination of the top secret Manhattan project. A three-yearong effort by some of the smartest people alive, including people like J. Robert Oppenheimer, John Vonoyman, and a littleknown mathematician named Stanislav Ulam. [10:29] Even after the war ended, Ulam continued trying to figure out how neutrons behave inside a nuclear bomb. Now, a nuclear bomb works something like this. Say you have a core of uranium 235. Then when a neutron hits a U235 nucleus, the nucleus splits, releasing energy and crucially two or three more neutrons. If on average those new neutrons go on to hit and split more than one other U235 [10:55] nucleus, you get a runaway chain reaction. So you have a nuclear bomb, but uranium 235, the fizzile fuel needed for the bombs, was really hard to get. So one of the key questions was just how much of it do you need to build a bomb? And this is why Ulam wanted to understand how the neutrons behave. But then in January of 1946, everything came to a halt. [11:20] Ulam was struck by a sudden and severe case of encphilitis, an inflammation of the brain that nearly killed him. His recovery was long and slow with Ulam spending most of his time in bed. To pass the time, he played a simple card game, solitire. But as he played countless games, winning some, losing others, one question kept nagging at him. What are the chances that a [11:46] randomly shoveled game of solitaire could be won? It was a deceivingly difficult problem to solve. Ulan played with all 52 cards where each arrangement created a unique game. So the total number of possible games was 52 factorial or about 8 * 10^ the 67. So solving this analytically was hopeless. But then Ulam had a flash of insight. [12:12] What if I just play hundreds of games and count how many could be won? that would give him some sort of statistical approximation of the answer. Back at Los Alamos, the remaining scientists grappled with much harder problems than solitire, like figuring out how neutrons behave inside a nuclear core. In a nuclear core, there are trillions and trillions of neutrons or interacting with their surroundings. So, the number of possible outcomes is immense, and [12:39] computing it directly seemed impossible. But when Ulam returned to work, he had a sudden revelation. What if we could simulate these systems by generating lots of random outcomes like I did with Solitaire? He shared this idea with Vonoyman who immediately recognized its power but also spotted a key problem. See, in solitaire, each game is independent. How the cards are dealt in one game have no effect on the next. But [13:07] neutrons aren't like that. A neutron's behavior depends on where it is and what it has done before. So you couldn't just sample random outcomes like in solitaire. Instead you needed to model a whole chain of events where each step influenced the next. What Venoyman realized is that you needed a mark of chain. So they made one and a much simplified version of it works something like this. Now the [13:34] starting state is just a neutron traveling through the core and from there three things can happen. It can scatter off an atom and keep traveling. So that gives you an arrow going back to itself. It can leave the system or get absorbed by a non-visile material in which case it no longer takes part in the chain reaction and so it ends its mark of chain. Or it can strike another uranium 235 atom triggering a fision event and releasing two or three more [14:01] neutrons that then start their own chains. But in this chain, the transition probabilities aren't fixed. They depend on things like the neutron's position, velocity, and energy, as well as the overall configuration and mass of uranium. So, a fastmoving neutron might have a 30% chance to scatter, 50% chance to be absorbed or leave, and a 20% chance to cause fishision. But a slower moving neutron would have different [14:27] probabilities. Next, they ran this chain on the world's first electronic computer, the ENIAC. The computer started by randomly generating a neutron starting conditions and stepped through the chain to keep track of how many neutrons were produced on average per run known as the multiplication factor K. So if on average one neutron produces another two neutrons then K is equal to two and if [14:52] on average every two neutrons produce three neutrons then K is equal to 3 over2 and so on. Then after stepping through the full chain for a specified number of steps, we collect the average K value and record that number in a histogram. This process was then repeated hundreds of times and the results tell it up, giving you a statistical distribution of the outcome. If you find that in most cases K is less [15:17] than one, the reaction dies down. If it's equal to one, there's a self- sustaining chain reaction, but it doesn't grow. And if K is larger than one, the reaction grows exponentially and you've got a bomb with it. Vonoyman and Ulam had a statistical way to figure out how many neutrons were produced without having to do any exact calculations. In other words, they could approximate differential equations that were too [15:43] hard to solve analytically. All that was needed was a name for the new method. Now, Ulam's uncle was a gambler, and the random sampling and high stakes reminded Ulam of the Monte Carlo Casino in Monaco, and the name stuck. The Monte Carlo method was born. The method was so successful that it didn't stay secret for long. By the end of 1948, scientists at another lab, [16:09] Argon in Chicago, used it to study nuclear reactor designs, and from there, the idea spread quickly. Ulam later remarked, "It is still an unending source of surprise for me to see how a few scribbles on a blackboard could change the course of human affairs, and it wouldn't be the last time a Markov chain-based method changed the course of human affairs. [16:35] In 1993, the internet was open to the public and soon it exploded. By the mid1 1990s, thousands of new pages appeared every day and that number was only growing. This created a new kind of problem. I mean, how do you find anything in this everexpanding sea of information? In 1994, two Stanford PhD students, Jerry Young and David Pho, founded the [17:01] search engine Yahoo to address this issue. But they needed money. So, a year later, they arranged to meet with Japanese billionaire Masayoshi Sun, also known as the Bill Gates of Japan. They were looking to raise $5 million for their new startup. But Sun has other plans. He offers to invest a full $100 million instead. That's 20 times more than what [17:28] the founders asked for. So, Jerry Yang declines, saying, "We don't need that much." But Sun disagrees. Jerry, everyone needs $100 million. Before the founders get a chance to respond, Sun jumps in again and asks, "Who are your biggest competitors?" Excite and LOS, the pair respond. Son orders his associate to write those names down. And then he says, "If you [17:53] don't let me invest in Yahoo, I will invest in one of them and I'll kill you." See, Sun had realized something. None of the leading search engines at the time had any superior technology. They didn't have a technological advantage over the others. They all just ranked pages by how often a search term appears on a given page. So, the battle for the number one search engine would be decided by who could attract the most [18:18] users, who could spend the most on marketing. &gt;&gt; Likos, go get it. &gt;&gt; Get los or get lost. This is Revolution. [Music] Yahoo. &gt;&gt; And marketing required a lot of money. Money that Sun had so he could decide who won the war. Yahoo's founders realized they were left with no real choice but to accept Sun's investment. [18:46] So here we are right in the middle of Yahoo. And within 4 years, Yahoo became the most popular site on the planet. In the time it takes to say this sentence, Yahoo will answer 79,000 information requests worldwide. The two men are now worth $120 million each. &gt;&gt; Yahoo. &gt;&gt; But Yahoo had a critical weakness. [19:11] See, Yahoo's keyword search was easy to trick. To get your page ranked highly, you could just repeat keywords hundreds of times, hidden with white text on a white background. One thing they didn't have in those early days was a notion of quality of the result. So they had a notion of relevance, saying, "Does this document talk about the thing that you're interested in?" But there wasn't really a notion of which ones are better. [19:39] &gt;&gt; What they really needed was a way to rank pages by both relevance and quality. But how do you measure the quality of a web page? Well, to understand that, we need to borrow an idea from libraries. So, I'm old enough that library books used to have a paper card in it that was a stamp of all the due dates of when it was due back. You took a book and if it had a lot of those, you said, "Oh, this is probably a good book." And if it didn't have any, you said, "Well, maybe this isn't the [20:04] best book." Stamps acted like endorsements. The more stamps, the better the book must be. And the same idea can be applied to the web. Over at Stanford, two PhD students, Sergey Brin and Larry Page, were working on this exact problem. Breen and Paige realized that each link to a page can be fought off as an endorsement and the more links a page sends out, the less valuable each vote becomes. So what they realized is [20:31] that we can model the web as a markoff chain. To see how this works, imagine a toy internet with just four web pages. Call them Amy, Ben, Chris, and Dan. These are our states. Typically, one web page links to others, allowing you to move between them. These are our transitions. In this setup, Amy only links to Ben, so there's a 100% chance of going from Amy to Ben. Ben links to Amy, Chris, and [20:58] Dan, so there's a 33% chance of going to any of those pages. And we can fill out the other transition probabilities in the same way. So now we can run this Markoff chain and see what happens. Imagine you're a surfer on this web. You start on a random page, say Amy, and you keep running the machine and keep track of the percentage of time you spend on each page. Over time, the ratio settles and the scores give us some measure of [21:25] the relative importance of these pages. You spend the most time on Ben, so Ben is ranked first, followed by Amy, then Dan, and lastly Chris. It might seem like there's an easy way to beat the system. Just make a 100 pages all linking to your website. Now you get a 100 full votes and you'll always rank on top, but that is not the case. While during their first few steps, they might make your page seem important, none of [21:51] the other websites link to them. So over many steps, their contributions don't matter. You might have many links, but they're not quality links, so they don't affect the algorithm. But there is still one problem, though. Not all pages are connected. In networks like this one, a random server can get stuck in a loop, never reaching the rest of the web. So to fix this, we can set a rule that 85% of the time, our random [22:18] server just follows a link like normal. But then for about 15% of the time, they just jump to a page at random. This damping factor makes sure that we explore all possible parts of the web without ever getting stuck. By using mark of chains, Paige and Brin had built a better search engine and they called it page rank &gt;&gt; because it's talking about how pages uh react web pages react with each other [22:43] and also because uh the founder's name is Larry page so he snuck that in. &gt;&gt; With page rank, they got much better search results, often getting you to the site you were looking for in one go. Although to some this sounded like a terrible idea. Others said, "Oh, well, you're telling me you get a search that will get the right result on the first answer." I don't want that because if it takes them three or four chances [23:08] searches to get the right answer, then I have three or four chances to show ads. And if you get them the answer right away, I'm just going to lose them. So, uh, you know, I don't see why better search is better. &gt;&gt; But Pitch and Brin disagreed. They were convinced that if their product was far superior, then people would flock to it. I would say it actually is a democracy that works. If all pages were equal, uh, anybody can manufacture as many pages as [23:34] they want. I can set up a billion pages on my server tomorrow. We shouldn't treat them all as equal. Uh, just looking at the data out of out of curiosity, we found that we had technology to do a better job of search and we realized how impactful having great search can be. &gt;&gt; And so in 1998, they launched their new search engine to take on Yahoo. Initially, they called it backup after the backlinks it analyzed. But then they realized that maybe that's not the most [24:01] attractive name. Now, their ambitions were big to essentially index all the pages on the internet and they needed a name equally as big. So, they thought of the largest number they could think of, 10 to the power 100, a Google. But then, when trying to register their domain, they accidentally misspelled it. And so, Google was born. Over [24:26] the next four years, Google overthrew Yahoo to become the most used search engine. &gt;&gt; Everyone who knows the internet almost certainly knows Google. &gt;&gt; Googling is like oxygen to teenagers. And today, Alphabet, which is Google's parent company, is worth around $2 trillion. &gt;&gt; When Google makes even the slightest change in its algorithms, it can have huge effects. Google Google. &gt;&gt; They're on fire. And the reason why [24:53] they're on fire is because they're focused. And they're more focused than Yahoo who does search. They're more focused than Microsoft who does search with Bing. Yahoo has lots of traffic. They always have. They have some really great properties, but I don't think Yahoo is the go-to place, you know. And at the heart of this trillion dollar algorithm is a mark of chain which only looks at the current state to predict what's going to happen next. But in the 1940s, Claude Shannon, the [25:19] father of information theory, started asking a different question. He went back to Marov's original idea of predicting text, but instead of just using vowels and consonants, he focused on individual letters. And he wondered, what if instead of looking at only the last letter as a predictor, I look at the last two? Well, with that, he got text that looked like this. Now it doesn't make much sense but there are some recognizable words like way of off [25:45] and the but Shannon was convinced he could do better. So next instead of looking at letters he wondered what if I use entire words as predictors that gave him sentences like this. The head and in frontal attack on an English writer that the character of this point is therefore another method for the letters that the time of whoever told the problem for an unexpected. Now, clearly this doesn't make any [26:11] sense, but Shannon did notice that sequences of four words or so generally did make sense. For instance, attack on an English writer kind of make sense. So, Shannon learned that you can make better and better predictions about what the next word is going to be by taking into account more and more of the previous words. It's kind of like what Gmail does when it predicts what you're going to type next. And this is no coincidence. The algorithms that make [26:38] these predictions are based on mark of chains. &gt;&gt; They're not necessarily using letters, you know, they they they use what they call tokens, some of which are letters, some of which are words, marks of punctuation, whatever. So, it's a it's a bigger set than just the alphabet. The game is simply we have this string of tokens that you know might be 30 long [27:04] and we're asking what are the odds that the next token is this or this or this. But today's large language models don't treat all those tokens equally because unlike simple markoff chains they also use something called attention which tells the model what to pay attention to. So in the phrase the structure of the cell, the model can use previous context like blood and mitochondria to know the cell most likely refers to biology rather than a prison cell and it [27:30] uses that to tune its prediction. But as large language models become more widespread, one concern is that the text they produce ends up on the internet and that becomes training data for future models. &gt;&gt; When you start doing that, the real the game is very soon over. You come in this case to a very dull stable state. It just says the same thing over and over and over again forever. The language [27:56] models are vulnerable to this process. &gt;&gt; And any system like this where we have a feedback loop will become hard to model using markoff chains. Take global warming for instance. As we increase the amount of carbon dioxide in the air, the average temperature of the earth increases. But as the temperature increases, the atmosphere can hold more water vapor, which is an incredibly powerful greenhouse gas. And with more water vapor, the temperature increases further, allowing for even more water [28:22] vapor. So you get this positive feedback loop which makes it hard to predict what's going to happen next. So there are some systems where marov chains don't work. But for many other dependent systems, they offer a way of doing probability. But what's fascinating is that all these systems have extremely long histories. I mean, you could trace back all the letters in a text, trace back all the interactions of what a neutron did, or trace back the weather for weeks. But [28:49] the beautiful thing Marov and others found is that for many of these systems, you can ignore almost all of that. You can just look at the current state and forget about the rest. That makes these systems memoryless. And it's this memoralist property that makes mark of chain so powerful because it's what allows you to take these extremely complex systems and simplify them a lot to still make meaningful predictions. [29:16] As one paper put it, problem solving is often a matter of cooking up an appropriate marov chain. &gt;&gt; It's kind of ridiculous to me that this basic fact of mathematics would come out of a fight like that which you know really had nothing to do with it. But all the evidence suggests that it really was this determination to show up the crossoff that led Marov to do the work. [29:41] &gt;&gt; But there's one question we still haven't answered when playing solitire. How did Ulam know his cards were perfectly shuffled? I mean, how many shuffles does it take to get a completely random arrangement of cards? &gt;&gt; If you have a deck of cards, you need to shuffle it, right? &gt;&gt; Okay. How often if you're shuffling like you know you split it in half and then you do the &gt;&gt; How often do you have to shuffle it to [30:07] make it completely random? &gt;&gt; Two. &gt;&gt; Two. I'm going with 26. &gt;&gt; Four times. &gt;&gt; Four times. &gt;&gt; I don't know. &gt;&gt; 52 times. &gt;&gt; Okay. Okay. It's not a bad guess. &gt;&gt; Seven. &gt;&gt; It is seven. Really? &gt;&gt; Yeah. So, you can think of card shuffling as a markoff chain where each deck arrangement is a state and then each shuffle is a step. And so for a deck of 52 cards, if you riffle shuffle it seven times, then every arrangement [30:33] of the deck is about equally likely. So it's basically random. But I can shuffle like that. So for me, what I do is I do it like this. How many times do you think you have to shuffle like this to get it random? What do you think? And perhaps more importantly, how would you go about working it out? Well, that's where today's sponsor, Brilliant, comes in. Brilliant is a learning app that gets you hands-on with problems just like [31:00] this. Whether it's math, physics, programming, or even AI, Brilliant's interactive lessons and challenges let you play your way to a sharper mind. You can discover how large language models actually work. From basic Markov chains to complex neural networks, or dig into the math behind this shuffling question. It's a fun way to build knowledge and skills that help you solve all kinds of problems. Which brings us back to our [31:25] shuffle. So, Casper, what actually is the answer? &gt;&gt; It's actually over 2,000. Over crazy, right? &gt;&gt; Yeah. &gt;&gt; So, the next time someone offers to shuffle before a game, make sure they're doing it right. Seven riffles or it doesn't count. But the interesting part isn't just knowing that. It's understanding why and seeing how a simple question can lead you to some surprisingly complex mathematics. And that's what Brilliant is all about. So, [31:52] to try everything Brilliant has to offer for free for a full 30 days, visit brilliant.org/veritassium. Click that link in the description or scan this handy QR code. And if you sign up, you'll also get 20% off their annual premium subscription. So, I want to thank Brilliant for sponsoring this video. And I want to thank you for watching. [32:21] Easy.