This video is about genes that gamble. The basic idea of natural selection, is that if a gene does
an above average job at helping its host creatures
survive and reproduce, it will tend to become more common as creatures compete with each
other over the generations. This tendency to survive and
reproduce is called fitness and you'll often hear
natural selection summarized as survival of the fittest. But one day a clever newly mutated gene realized another strategy was possible. If copies of the gene exist in
multiple different creatures, the gene can do better
by causing the creatures to help each other, rather than mercilessly
competing with each other. This concept is known
as inclusive fitness. The only problem is, the copies of a gene are hidden inside the creatures and they can't see each other. So if the copies of the gene
want to help each other, they have to gamble, sometimes helping the
competing genes by accident. So the question is, how
can a gene strategize around inclusive fitness without
the whole plan backfiring? The condition for making
inclusive fitness gambling work, is called Hamilton's rule. And that's what we're going to build too. It's a pretty simple looking inequality. And if you've learned about
Hamilton's rule before, you might be wondering why the
heck is the video is so long? Well, it turns out that the simplicity of Hamilton's rule is a bit deceptive or at least it deceived me at first. So this video is going to go slowly, starting with the general requirement for gambling to be beneficial, and then applying that idea to simulations of increasingly
complex biological systems. As we build, something will go wrong and when it does, you
might not realize it, you might be deceived just like I was. it'll get fixed before
the end of the video, but consider it a challenge
to follow closely enough to see what's going wrong
before I tell you about it. So let's start by playing a game. It costs one coin to play, then you can roll a dice. If it comes up six, you win seven coins. Otherwise you get nothing. Let's let this blob play for a bit while we try to predict what will happen. Okay, so there are six possible outcomes and we can summarize each with an equation where the payout minus the
cost equals the net gain. If the dice lands on a
number from one to five, the payout is zero and the cost is one, leading to a net gain of negative one in each case, or a loss of one if you
prefer to say it that way. If the dice ends on a six
though, the payout is seven. So the net gain for that case is six. On a fair dice, these six possible results are all equally likely. So we can combine the equations together and divide everything by six to get the average
payout cost and net gain. One way to read this equation, is to say you have a one in six chance to win the benefit of seven coins and it costs one coin to play. So you expect to win one sixth of the coin per time you play. Then coins only come in whole numbers, but the average is a fraction. An average predicted result
like this has a special name, it's called an expected value. And since the expected
value here is positive, the blob should gain money over
time by continuing to play. It looks like the blob was
actually doing way better than one sixth of a coin on average. That's good for the blob, but not so good for our prediction. It's only been a few roles though so maybe the blob is just getting lucky. If our prediction is good, it should start to look more accurate with a larger number of roles. So let's enlist some more
blobs to see if that happens. (gentle upbeat music) Well, it's starting to get pretty close. It can sometimes take surprisingly long for random events to even out,
which is my favorite excuse whenever I'm getting my
butt kicked in a board game. We can use variables to
write this out in a way that will apply to a
broader set of situations. The benefit of winning, times the probability of winning, minus the cost to play
is the expected value of a gambling game. If the expected value is positive, it's usually a good idea to gamble. And when the expected value is negative, like in every single
casino game for example, you should expect to lose money. You might notice that this
looks basically the same as Hamilton's rule already. So let's try applying it
to a biology simulation to see how it works. We'll start with the same basic structure from the video on green beard altruism. Each day, blobs will go out to
the forest to eat some fruit. Some of the trees have
predators in them though, and if the blobs are unlucky enough to visit a tree with a predator
in it, they'll get eaten. But if they don't get eaten, they'll head to one of
the homes and reproduce, creating a puddle of
three new identical blobs in their place. And yes, a group of blob siblings is officially called a puddle. And after the blobs
reproduce, the cycle repeats. Also when it's time to go home, there might not be enough
homes to go around. In which case, some
randomly determined blobs won't get to go home and reproduce. In case you've seen
that green beard video, I want to highlight the
key difference here. This time, the siblings
always stick together in their puddle when
they go out to a tree. There's no altruism yet, but let's make this a bit bigger and let it run for a while to understand how the simulation works in this baseline case. (gentle upbeat music) All right, it turns out that the blobs thrive in this environment and the limiting factor ends
up being the supply of houses. The blobs should really figure out a way to build more housing, but comments like that belong
in the economic series. Okay, now let's add the
ability to be altruistic. Again, this'll be pretty similar to what we saw in the green beard video. When the blobs go to a
tree with a predator in it, one of them will notice the predator and it'll have two
options for how to react. The first is to just run away, leaving the other blobs to die. We will call this the cowardly behavior. The second option will be
to make a bunch of noise to warn the other blobs, but in the process, attract
the predators attention and end up getting eaten. Because these bombs are
sacrificing themselves to help others, we'll call
this the altruistic behavior. The behavior will be controlled by a gene which has two versions or alleles. The cowardly allele will be blue and the altruism allele will be orange. The blobs can't actually see the genes, but we're going to use these colors to graph the frequency
of each allele over time. I mentioned this in basically every video, but I can't say enough how in real life, the cause of behaviors is very complex. It's only partly genetic and the genetic part itself
is a lot more complicated than this model we're using here where just one gene controls
this one kind of behavior. We're just using a simple model to explore one small piece of the very large picture of behavior. But with that said, let's
run this simulation. We'll start with equal
numbers of each allele, before we hit go though, what
do you think will happen? Will want to allele takeover? If so, which one? Try using that expected value
idea we talked about earlier and keep in mind that
the puddles stay together when they go to find food. (gentle upbeat music) This graph shows the frequencies
of each allele over time, stacked on top of each other. At the beginning it's half and half, but over time, the orange altruism allele drove the other ilial to extinction. Let's see if we can make sense of why the altruism allele did so well. Just like before, we'll look
at the benefit of the behavior, times the probability
of getting the benefit, minus the cost of the behavior
to get the expected value, but instead of coins, we're worried about copies
of the altruism allele. The blob that notices the
predator, could have survived, but instead sacrifices itself, destroying one copy of
the altruism allele. So the cost of the
altruistic behavior is one and the benefit is that
two sibling blobs live when otherwise they would have died. And since they're genetically identical, there is a 100% chance that the siblings have
the altruism allele. So the probability P of
getting the benefit, is one and the expected value is a gain of one copy of the altruism allele. it's kind of weird to look at this and see a gain when one of the blobs dies, but we're comparing the effect
of the altruistic behavior to the effect of the other option, which is just running away and
leaving both siblings to die. A predator attacking is always bad, but it's less bad for the altruism allele because there are two
survivors instead of one. So that all seems to make sense, but we should do more runs to check that we didn't just fool ourselves with one unluckily unlikely simulation. It does happen, in science you got to try to prove yourself wrong. This graph summarizes all 30 runs. Each thin black line is one run and the thick black line is the average. So yeah, the orange altruism allele takes over the population
pretty consistently. In hindsight, that's not too surprising, there's only one possible outcome with the altruistic behavior and it's positive for the allele. So it's not even really a gamble. Now let's make it more interesting by adding sexual reproduction, to mix up the alleles and add uncertainty. Now, when creatures go
home at the end of the day, two creatures will go to each home. And when they produce their puddle of three offspring together, each offspring will get a copy of one of the parent's alleles, with each parent, having an equal chance of
passing to each offspring. If you've learned about genetics before, you might've learned about creatures that have two alleles for
each gene in their genome, instead of just one. And in that case, each
offspring gets one allele from each parent. The word for that is diploid. That's how humans and
most other animals work, but some organisms do have just one copy. The word for that is haploid and at least for now, we're
going to stick with that. Okay, for this simulation, let's make our prediction together. Just like in the previous simulation, sounding the alarm will
cost a blob it's life and cost of the altruism
allele one of its copies. And the benefit is still two, since two blobs will be saved, but it's no longer certain that the siblings will also
carry the altruism allele. The sexual reproduction
is mixing up the alleles, so P is no longer equal to one like it was with asexual reproduction. At the other extreme, if P were all the way down to zero, both siblings would definitely
not share the allele and the expected net value to the allele would be negative one, but realistically it will
be somewhere in between. So to figure out the value of P here, let's bring back the sacrificer blob and focus on just one sibling. We're already in a
situation where the blob who notices the predator
has the altruism allele. So we know that at
least one of the parents also had the allele. That's where the sacrifice
allele came from. The sibling could have gotten it's allele from that same parent or the other parent, each possibility is equally likely, each happening 50% of the time. When both siblings get the
allele from the same parent, we have a special name for it. The two alleles are identical by descent. In this case, the sibling definitely has the altruism allele. So let's put that 50%
chance into the value for P, but we're not done yet. And the other possibility where the sibling got it's
allele from the other parent, it could be either kind of allele. Since the mating is random, the chance that the other parent also had the altruism allele,
is the same as the frequency of the altruism allele
in the whole population, but that number is going
to change over time so unfortunately this P
won't have just one value. If you're new to
calculating probabilities, this might feel like a bit much, don't worry, it can take some time and practice for that
kind of thing to sink in, but to summarize this, there are two ways for the sibling to also have the altruism allele, it can be identical by descent, or it can be from the other parent and just happened to
be the altruism allele because there are copies floating
around in the population. The fact that P depends on the frequency of the altruism allele,
is a little bit icky, but we can still say some
things about the starting case and the best case and the worst case. First, we're going to start the simulation with 50% of each allele. So the probability P will
start at 75% or 0.75. If we plugged that into the
expected value equation, we get 0.5, that's positive. So we should expect the altruism allele to do well at the beginning,
increasing its frequency, causing P to go up more as time goes on, again, raising the
expected value and so on, and so on, leading to total domination, which is the best case. And even in the worst case, the frequency of the altruism allele can't go any lower than zero. So P can never go below 0.5,
meaning be expected value of the behavior can't go below zero. It's technically possible for the altruism allele
to go extinct anyway, but there can literally never
be a negative expected value for the behavior. So it would be very surprising. So my money is on the altruism
allele taking over again. What do you think? If you think there's a
flaw in this reasoning, now it would be your
chance to point it out. A hindsight explanation isn't worth as many points as a prediction, but why am I saying this? My prediction is obviously
logical and flawless and I'd never make a mistake,
let alone put it on YouTube. (upbeat music) Well, that's gotta be a fluke. So again, let's run it a bunch of times and look at the average result to wash away that bad luck. (upbeat music) All right, you caught me. There's something wrong
with that previous analysis and don't worry, I've checked the code, it's the prediction that's
wrong, not just the simulation. I know I said hindsight
explanations aren't worth as much, but if I'm being honest,
it's what I had to do. And there's nothing wrong with understanding something in hindsight, as long as you test that understanding and new situations to
make sure it holds up. Anyway, take a minute to see
if you can figure out the flaw. You might've noticed
that the only difference between our calculation
and Hamilton's rule, is that Hamilton's rule uses
this letter R instead of P. If you're like me, you originally assumed that R and P are just different
labels for the same thing. R stands for relatedness and it's not the probability that another creature shares
the allele in question, that's P. R is the probability that
another creature's allele is identical by descent. And if it's not obvious to you how that makes everything fall
into place, you're not alone, but we'll get there. This is a competitive environment where the total population size is capped by the number of available homes. An allele succeeds in a
competitive environment when its frequency increases over time, when it becomes a greater
and greater fraction of the alleles in a population. Alleles can only make progress at the expense of other alleles. So to make a good prediction, we'd have to consider that
competition more carefully, instead of just focusing
on the number of copies of the altruism allele. If the population starts
out half and half, we can increase the frequency
of the orange alleles by adding a group of alleles that's more than half orange. It's okay if we had some blue ones too, as long as more than half are orange. And if the population gets to a point where say 90% of the alleles are orange, then adding more than half
orange, won't be good enough, we'd have to add a group
that's more than 90% orange. Ideally 100% of the alleles
we add would be orange, but unfortunately we don't
have a way to guarantee that. But as long as the fraction
of orange alleles we add, is more than the current
frequency of orange alleles, the frequency will go up. So this is the true task
of the altruistic behavior. On average of the alleles it saves, the fraction that are orange, needs to be greater than the
current frequency of orange, orange being the altruism allele. It's possible to write this
down in a little bit more detail and do some algebra, and then Hamilton's rule pops out. We're not going to do that right now, but it happens in a way I
didn't expect when I tried it. So it might be an interesting puzzle if you're curious about it, but at least for me, it's more intuitive to examine our misguided expected value calculation from before. The key difference is this second part of our expression for P. It deals with the saved alleles that are not identical by descent. This group of alleles has the same makeup as those in the broader population. So you can help this
group as much as you want, but on average, that won't
affect the frequency. Our original calculation only
ignored the cowardly alleles. So it had a lopsided view. The remaining part of T
deals with the siblings whose alleles are identical by descent. And this group, since it's
100% altruism alleles, will have an effect on the frequency if you add them to the pool. And this is actually just the same thing as R that appears in Hamilton's rule. For siblings R is one half,
like we worked out before when we thought about
where the alleles could go and each kind of relationship
has its own value. And you can calculate R
for any given situation by tracing where the alleles might go, but we're not going to
get into that right now. So Hamilton's rule includes
the effect on alleles that are identical by descent,
which affects the frequency, and it includes the cost
to the altruism allele, which also affects the frequency, but it ignores the group
that's not identical by descent because that won't affect the frequency. It still feels a little bit magical to me that it looks like a plain
expected value condition, but it neatly ignores
everything that's neutral with respect to the current frequencies. If we look back at the
most recent simulation, we see that B times R
minus C is exactly zero. So now it makes sense that the
alleles were evenly matched, but we should also test a situation that does satisfy Hamilton's rule. Just a small change to do it. So let's reduce the death chance for a creature who sounds
the alarm from 100% to 95%, totally going to work, right? (upbeat music) Okay, we do see the altruism allele increase in frequency on average. The average didn't quite make
it to 100% in the 400 days that let the sims run, but we can see that it's well on its way. In some of the runs, the altruism allele did have a pretty rough start, so we can see how it's possible
for an allele to go extinct despite satisfying Hamilton's rule, but at least for this set of 30 runs, even the unluckiest run
was able to recover. So there is a lot more we could do, but this video is pretty long already and frankly, I think we could
both use a break for now, but to give you an idea, here are some other things we
could explore in the future. We could check Hamilton's
rule in different situations and with different values of relatedness. We could talk more about the concept of relatedness in general. We could check whether an
allele definitely fails if it doesn't satisfy Hamilton's rule. We could see what happens when there are more than
two competing alleles. We could look at a
deployed genetic structure just to make sure Hamilton's
rule still holds up there, and we could actually do
that more rigorous derivation I mentioned earlier, and we'll probably do some
of that in future videos, but the next main installment
in the altruism series, will be about situations that
Hamilton's rule can't explain. Hamilton's rule only applies to systems where the
organisms are relatives and altruism goes in one direction. In many situations, though,
especially in humans, cooperation goes two ways or even happens in a complex web and is often not between close relatives. So that'll be a fun thing to explore. As always, thanks for watching. (upbeat music)