1
00:00:00,150 --> 00:00:03,240
Back, I want to talk a
little more about this idea
2
00:00:03,240 --> 00:00:04,950
that I introduced in the last video,
3
00:00:04,950 --> 00:00:09,210
which is the fact that
whenever we have mechanisms
4
00:00:09,210 --> 00:00:11,610
or events governed by fixed rate
5
00:00:11,610 --> 00:00:14,430
that occur regardless
of what happened before,
6
00:00:14,430 --> 00:00:17,974
we call that a Poisson
process in both discrete time
7
00:00:17,974 --> 00:00:19,560
or in the limit of very
small discrete steps,
8
00:00:19,560 --> 00:00:20,673
continuous time.
9
00:00:22,740 --> 00:00:24,540
And really I wanted to talk a little more
10
00:00:24,540 --> 00:00:26,760
about the mathematics of these processes
11
00:00:26,760 --> 00:00:29,700
because we encountered two
problem in trying to code up
12
00:00:29,700 --> 00:00:33,840
a very simple random or
stochastic simulation
13
00:00:33,840 --> 00:00:35,700
of a simple model.
14
00:00:35,700 --> 00:00:38,880
So one of those is that what
happens is if those rates
15
00:00:38,880 --> 00:00:39,903
are very high?
16
00:00:40,739 --> 00:00:43,680
How do we make it so that the probability
17
00:00:43,680 --> 00:00:47,733
in any one step of something
occurring is smaller than one?
18
00:00:48,840 --> 00:00:52,740
The other one is if those
probabilities are very high,
19
00:00:52,740 --> 00:00:54,718
you can have multiple events
happening at the same time,
20
00:00:54,718 --> 00:00:56,013
and you don't want that.
21
00:00:56,957 --> 00:00:59,520
I don't wanna both infect and recover,
22
00:00:59,520 --> 00:01:01,980
infect someone with a disease
and recover from the disease
23
00:01:01,980 --> 00:01:03,030
at the same time.
24
00:01:03,030 --> 00:01:08,030
Really it's, the model, the
system that we're thinking of
25
00:01:08,100 --> 00:01:09,840
doesn't have those simultaneous event.
26
00:01:09,840 --> 00:01:12,120
One has to happen before the other.
27
00:01:12,120 --> 00:01:15,093
So we don't want our random
simulation to do that.
28
00:01:16,470 --> 00:01:18,060
So we want to think about what happens,
29
00:01:18,060 --> 00:01:21,093
how do we deal with
competing Poisson processes?
30
00:01:23,943 --> 00:01:27,527
Okay, so here's how to
think about it, right?
31
00:01:30,600 --> 00:01:33,720
Let's say we're only
dealing with people leaving,
32
00:01:33,720 --> 00:01:36,960
so our departure term from
the cloning factory, right?
33
00:01:36,960 --> 00:01:39,960
Well, what is the
probability that they leave
34
00:01:39,960 --> 00:01:41,400
in the first step?
35
00:01:41,400 --> 00:01:45,933
So someone in the clone factory.
36
00:01:50,730 --> 00:01:51,563
Whoops.
37
00:01:53,970 --> 00:01:55,840
In the clone factory
38
00:02:00,960 --> 00:02:05,670
leaving in first step.
39
00:02:10,110 --> 00:02:11,820
Well that's pretty simple, right?
40
00:02:11,820 --> 00:02:16,410
So if I say that I have a
departure rate or a leaving rate,
41
00:02:16,410 --> 00:02:20,460
which we call l, and an increment of time
42
00:02:20,460 --> 00:02:22,773
that we call t, delta t,
43
00:02:24,660 --> 00:02:27,740
we said we simply test l times delta t
44
00:02:27,740 --> 00:02:30,540
if is my random number smaller than that.
45
00:02:30,540 --> 00:02:33,540
So the probability that
I leave in the first step
46
00:02:33,540 --> 00:02:36,543
should be l times delta t.
47
00:02:40,680 --> 00:02:44,080
The probability that
I leave in second step
48
00:02:48,390 --> 00:02:52,260
would simply be me not
leaving in the first step,
49
00:02:52,260 --> 00:02:53,943
one minus l delta t,
50
00:02:55,500 --> 00:02:57,750
then leaving in the second one.
51
00:02:57,750 --> 00:03:01,500
So the first time, first day,
first step in the process,
52
00:03:01,500 --> 00:03:03,780
you go over me, you ask
me, do you choose to leave?
53
00:03:03,780 --> 00:03:05,670
Roll the dice, no.
54
00:03:05,670 --> 00:03:06,930
And then in the second step.
55
00:03:06,930 --> 00:03:09,270
Do you choose to leave roll the dice? Yes.
56
00:03:09,270 --> 00:03:12,390
I run a random number
smaller than l times delta t,
57
00:03:12,390 --> 00:03:13,983
I choose to leave, okay.
58
00:03:14,850 --> 00:03:16,680
Well here, what I want to talk about,
59
00:03:16,680 --> 00:03:18,660
the reason I'm going through
this is I want to talk about
60
00:03:18,660 --> 00:03:20,850
what happens if we
renormalize rates, right?
61
00:03:20,850 --> 00:03:24,090
So if l times delta t is
too big, let's say it's 1.2,
62
00:03:24,090 --> 00:03:26,880
everyone's gonna leave and
it doesn't matter if it's 1.2
63
00:03:26,880 --> 00:03:30,780
or 1.5, people are not leaving faster,
64
00:03:30,780 --> 00:03:32,643
they're limited by this delta t.
65
00:03:33,570 --> 00:03:35,673
So I could renormalize, right?
66
00:03:37,110 --> 00:03:40,650
By that I just mean, you know,
67
00:03:40,650 --> 00:03:43,170
sort of divide this delta t by something.
68
00:03:43,170 --> 00:03:46,320
So let's say that we
now have delta t tilda,
69
00:03:46,320 --> 00:03:49,770
which I'm just gonna
call delta t over two.
70
00:03:49,770 --> 00:03:53,220
So instead of days we're
thinking of half days,
71
00:03:53,220 --> 00:03:55,740
or instead of hours, we're
thinking of half hours.
72
00:03:55,740 --> 00:03:57,243
That's sort of the process.
73
00:03:58,980 --> 00:04:03,930
Okay, well, what I wanna see
is if I renormalize like that,
74
00:04:03,930 --> 00:04:06,370
how much of a difference
does it really make
75
00:04:07,830 --> 00:04:10,590
between this renormalize
stochastic simulation
76
00:04:10,590 --> 00:04:15,090
and the previous stochastic
simulation with delta t?
77
00:04:15,090 --> 00:04:19,233
Well, now the probability of
leaving in the first delta t,
78
00:04:24,120 --> 00:04:26,260
so leaving in first delta t
79
00:04:30,810 --> 00:04:35,760
is, well, I either leave in the
very first delta t over two,
80
00:04:35,760 --> 00:04:37,863
which is what I'm testing over now.
81
00:04:40,320 --> 00:04:42,870
So if I do that, that's good.
82
00:04:42,870 --> 00:04:47,870
Or I choose not to leave in
the first delta t over two,
83
00:04:48,030 --> 00:04:52,420
and I leave in the second
84
00:04:53,610 --> 00:04:54,783
delta t over two.
85
00:04:56,370 --> 00:05:00,453
By the way, I said I
anthropomorphize a lot.
86
00:05:03,000 --> 00:05:05,970
Whenever I say I choose to
leave or I choose not to leave,
87
00:05:05,970 --> 00:05:07,050
that's just wrong, right?
88
00:05:07,050 --> 00:05:09,270
It's just a pure roll of the dice.
89
00:05:09,270 --> 00:05:12,600
Does the gut of the dice
90
00:05:12,600 --> 00:05:15,060
choose to make that person leave or not,
91
00:05:15,060 --> 00:05:17,553
the random number generator
being the gut here?
92
00:05:18,750 --> 00:05:20,733
Okay, so this is what I have.
93
00:05:21,960 --> 00:05:26,580
Well, I'm gonna have this l
times delta two over two here,
94
00:05:26,580 --> 00:05:29,640
another l times t delta two over here,
95
00:05:29,640 --> 00:05:31,110
and then some other term.
96
00:05:31,110 --> 00:05:33,880
So really what I have is l times delta t
97
00:05:35,430 --> 00:05:40,430
minus l delta t over two squared.
98
00:05:41,160 --> 00:05:45,270
Okay, so I'm pretty close to
what I had originally now,
99
00:05:45,270 --> 00:05:48,210
just with a correction factor here.
100
00:05:48,210 --> 00:05:49,043
Interesting.
101
00:05:50,850 --> 00:05:53,913
With the probability of
leaving in second step,
102
00:05:57,490 --> 00:05:59,477
in the second delta t, right?
103
00:06:04,590 --> 00:06:06,740
Well, that one's a
little more complicated.
104
00:06:08,040 --> 00:06:10,320
So regardless, I need to not leave
105
00:06:10,320 --> 00:06:12,990
in the first two delta t over two,
106
00:06:12,990 --> 00:06:16,860
that's one minus l delta t over two.
107
00:06:16,860 --> 00:06:20,193
So I don't leave in the first
two half day or half hours.
108
00:06:21,810 --> 00:06:24,033
And then I could leave in the third one.
109
00:06:27,090 --> 00:06:30,153
Or I don't leave in the first three,
110
00:06:33,450 --> 00:06:38,450
and I leave in the fourth one, right?
111
00:06:38,580 --> 00:06:41,130
If you're getting confused
here, just think of it this way.
112
00:06:41,130 --> 00:06:45,400
The first calculation we did
way over here at the beginning
113
00:06:46,620 --> 00:06:49,050
was looking at whether people
were leaving in the first
114
00:06:49,050 --> 00:06:53,310
or second step where step
is in steps of delta t.
115
00:06:53,310 --> 00:06:55,863
So either left initially
or in the second one.
116
00:06:57,870 --> 00:07:00,470
What we're doing now
after the renormalization
117
00:07:00,470 --> 00:07:02,043
is just testing more.
118
00:07:03,450 --> 00:07:05,820
So you can leave in the
first delta two over two
119
00:07:05,820 --> 00:07:08,190
or the second one, which both mean leaving
120
00:07:08,190 --> 00:07:11,010
in the first delta t, or you
can leave in the third delta t
121
00:07:11,010 --> 00:07:12,450
over two or the fourth one,
122
00:07:12,450 --> 00:07:16,323
which both mean leaving in
the second delta t, okay?
123
00:07:18,240 --> 00:07:20,640
I think I erased something
important here. Oops.
124
00:07:21,840 --> 00:07:23,823
Over two, okay.
125
00:07:24,930 --> 00:07:29,133
Well, if you do the math of
like expending all of these,
126
00:07:31,230 --> 00:07:33,250
essentially what you're gonna get here
127
00:07:41,910 --> 00:07:43,290
is something pretty simple.
128
00:07:43,290 --> 00:07:47,853
So you're gonna get,
trying to do it quickly.
129
00:07:49,530 --> 00:07:53,190
You're gonna get, now then
the t over two from this,
130
00:07:53,190 --> 00:07:54,753
you're gonna get two of those.
131
00:07:56,460 --> 00:07:58,500
So you're gonna get your l delta t,
132
00:07:58,500 --> 00:08:01,083
which is gonna be the
same as this term here.
133
00:08:04,290 --> 00:08:05,883
You're gonna get your,
134
00:08:07,717 --> 00:08:10,337
you're gonna get two l delta t squared
135
00:08:11,910 --> 00:08:14,493
over two where the two is in squared.
136
00:08:18,330 --> 00:08:20,380
And that's gonna be again your term here.
137
00:08:21,990 --> 00:08:24,180
And then you're gonna
get in the same thing.
138
00:08:24,180 --> 00:08:28,143
You're gonna get some some
third and fourth order term,
139
00:08:29,820 --> 00:08:33,303
and by that I mean proportional
to delta t over three.
140
00:08:35,340 --> 00:08:36,990
Okay, so it's sort of the same thing.
141
00:08:36,990 --> 00:08:39,840
We're still getting the same probability
142
00:08:39,840 --> 00:08:42,270
to first approximation of getting out
143
00:08:42,270 --> 00:08:43,770
in the first or second step,
144
00:08:43,770 --> 00:08:46,320
and then we have some
order-order comparison.
145
00:08:46,320 --> 00:08:49,290
What this means is that if
our delta t are pretty big,
146
00:08:49,290 --> 00:08:52,320
if our probabilities l times delta t,
147
00:08:52,320 --> 00:08:53,820
maybe I should keep an l here,
148
00:08:54,750 --> 00:08:58,980
are pretty big, whenever
we renormalize our rates,
149
00:08:58,980 --> 00:09:01,590
we're not gonna get exactly
the same dynamics, right?
150
00:09:01,590 --> 00:09:04,680
We're gonna get some
correction terms all over.
151
00:09:04,680 --> 00:09:07,290
But if our l times delta t
gets really, really small,
152
00:09:07,290 --> 00:09:10,173
imagine that l times
delta t is one in 1,000.
153
00:09:11,430 --> 00:09:14,763
Well, this l times
delta t cubed, you know,
154
00:09:15,852 --> 00:09:17,700
goes from 10 to the minus
three to 10 to the minus nine.
155
00:09:17,700 --> 00:09:19,290
And that's tiny, right?
156
00:09:19,290 --> 00:09:21,300
So the smaller our rates are,
157
00:09:21,300 --> 00:09:24,330
eventually those error
terms don't matter anymore,
158
00:09:24,330 --> 00:09:27,300
and renormalizing your rates don't matter.
159
00:09:27,300 --> 00:09:29,610
So one easy way to like solve this problem
160
00:09:29,610 --> 00:09:32,460
is just to use small discrete increment,
161
00:09:32,460 --> 00:09:34,140
and then you're free.
162
00:09:34,140 --> 00:09:36,060
You know, if you make
sure that all your rates
163
00:09:36,060 --> 00:09:38,940
are at most of the order of one in 1,000,
164
00:09:38,940 --> 00:09:41,130
all your your rates time delta t,
165
00:09:41,130 --> 00:09:43,650
then you're free to renormalize
sort of as you please,
166
00:09:43,650 --> 00:09:46,080
and you know that the errors that you make
167
00:09:46,080 --> 00:09:47,883
are gonna be tiny, right?
168
00:09:49,500 --> 00:09:51,750
So that's one way to
get around the problem
169
00:09:51,750 --> 00:09:54,360
of what if my rates are
really big, just renormalize.
170
00:09:54,360 --> 00:09:57,780
You were thinking in terms of
discrete steps that were days,
171
00:09:57,780 --> 00:10:00,330
think in terms of discrete
step that are minutes,
172
00:10:00,330 --> 00:10:01,770
and now it's gonna be pretty smooth
173
00:10:01,770 --> 00:10:03,960
and you're not gonna have any problem.
174
00:10:03,960 --> 00:10:05,493
So that's one easy thing.
175
00:10:06,870 --> 00:10:09,450
The more interesting thing,
and here I'm gonna go
176
00:10:09,450 --> 00:10:12,330
a little deeper in the
math, is this idea of
177
00:10:12,330 --> 00:10:14,403
what if I can do two things, right?
178
00:10:15,810 --> 00:10:18,960
So you might have like my face over this.
179
00:10:18,960 --> 00:10:23,960
So what if I have competing processes?
180
00:10:24,000 --> 00:10:28,080
Which is what we had in
the cloning building,
181
00:10:28,080 --> 00:10:31,560
in the clone factory because
people could both leave
182
00:10:31,560 --> 00:10:33,240
or get cloned, and the question is
183
00:10:33,240 --> 00:10:35,100
which one do I do first, right?
184
00:10:35,100 --> 00:10:37,113
So here what we want to talk about is,
185
00:10:38,256 --> 00:10:39,810
let's focus again on just one person
186
00:10:39,810 --> 00:10:41,220
and let that person be me.
187
00:10:41,220 --> 00:10:44,190
Okay, so I entered a clone
factory, then the question is,
188
00:10:44,190 --> 00:10:47,373
at every delta t I'm gonna be
asked, do you choose to leave?
189
00:10:48,240 --> 00:10:51,450
And I can only get cloned
while I'm in the building.
190
00:10:51,450 --> 00:10:54,640
So really what I want
to know beforehand is
191
00:10:55,680 --> 00:10:58,260
how long am I gonna stay
in this building, right?
192
00:10:58,260 --> 00:11:00,813
So what is the period of time,
193
00:11:03,330 --> 00:11:06,570
let's call it l, so the
duration l for length,
194
00:11:06,570 --> 00:11:10,293
length of time that someone,
195
00:11:12,300 --> 00:11:15,183
and that's me, stays in the building.
196
00:11:19,800 --> 00:11:20,633
Okay.
197
00:11:22,260 --> 00:11:26,010
Well, the easiest way to derive
this for Poisson processes,
198
00:11:26,010 --> 00:11:28,740
or the way that's most intuitive to me
199
00:11:28,740 --> 00:11:30,903
is to go through the cumulative,
200
00:11:32,790 --> 00:11:34,350
I'll spell it out for this one,
201
00:11:34,350 --> 00:11:39,123
cumulative distribution function.
202
00:11:43,680 --> 00:11:46,500
I wasn't even sure saying the word.
203
00:11:46,500 --> 00:11:49,020
It's usually just called CDF, right?
204
00:11:49,020 --> 00:11:53,400
So this is a function
as a function of time,
205
00:11:53,400 --> 00:11:57,450
let's say l that starts at zero.
206
00:11:57,450 --> 00:12:00,360
So there's a probability
zero that you don't stay
207
00:12:00,360 --> 00:12:02,160
in the building at all
because I'm sort of saying
208
00:12:02,160 --> 00:12:03,900
I'm in the building.
209
00:12:03,900 --> 00:12:07,470
And this is gonna go up in some way,
210
00:12:07,470 --> 00:12:08,820
but can't go beyond one
211
00:12:08,820 --> 00:12:12,090
'cause it's just a sum of probabilities.
212
00:12:12,090 --> 00:12:14,940
So essentially here what I'm calculating
213
00:12:14,940 --> 00:12:18,003
is what's the probability that I've left.
214
00:12:20,400 --> 00:12:22,200
And I shouldn't use the same l here.
215
00:12:24,489 --> 00:12:26,580
Let's just call it t.
216
00:12:26,580 --> 00:12:29,610
So it's the probability that
I've left before time t,
217
00:12:29,610 --> 00:12:33,510
so it's zero at t equals zero,
and it initially goes up,
218
00:12:33,510 --> 00:12:34,920
and eventually it's gonna be one.
219
00:12:34,920 --> 00:12:36,480
What's the probability that someone
220
00:12:36,480 --> 00:12:38,640
has left before one million years?
221
00:12:38,640 --> 00:12:39,473
It's one, right?
222
00:12:39,473 --> 00:12:41,800
Nobody's staying in the
building for that long.
223
00:12:43,470 --> 00:12:46,490
So what does that look
like? So let's call it...
224
00:12:48,360 --> 00:12:50,790
I'm just gonna use l for all like things.
225
00:12:50,790 --> 00:12:53,553
So hopefully it doesn't get too confusing.
226
00:12:59,370 --> 00:13:04,290
So here, to be able to do math,
227
00:13:04,290 --> 00:13:05,670
we're gonna have to take the limit
228
00:13:05,670 --> 00:13:07,800
of very small time step delta t.
229
00:13:07,800 --> 00:13:12,800
Like I said when we were
talking about renormalization,
230
00:13:12,810 --> 00:13:14,820
as delta t goes to zero,
231
00:13:14,820 --> 00:13:17,700
then the scale of our discrete
process doesn't matter.
232
00:13:17,700 --> 00:13:19,560
It doesn't matter because
now we have essentially
233
00:13:19,560 --> 00:13:21,360
a continuous time dynamics,
234
00:13:21,360 --> 00:13:23,710
and it makes it a lot
easier to do math, right?
235
00:13:30,240 --> 00:13:33,390
And I'm gonna explain what
I'm writing in a second, okay?
236
00:13:33,390 --> 00:13:38,390
So the probability that I've
left in a time smaller than t,
237
00:13:39,360 --> 00:13:42,300
than l, sorry, the
probability that I've left
238
00:13:42,300 --> 00:13:45,753
in a time smaller than l,
which is what this mean,
239
00:13:46,890 --> 00:13:50,940
well, it's everything but
people that are still there.
240
00:13:50,940 --> 00:13:53,580
So whenever you say
everything but in probability,
241
00:13:53,580 --> 00:13:55,140
that means one minus,
242
00:13:55,140 --> 00:13:58,470
everything but the people
that are still there.
243
00:13:58,470 --> 00:14:01,140
And the people that are still there
244
00:14:01,140 --> 00:14:02,970
through all the time steps,
245
00:14:02,970 --> 00:14:04,980
and how many time steps have we taken?
246
00:14:04,980 --> 00:14:07,413
It's l divided by delta t, right?
247
00:14:08,550 --> 00:14:13,550
So this here is number
of steps that we've done.
248
00:14:14,430 --> 00:14:17,940
So if l is a million year
and delta t is a year
249
00:14:17,940 --> 00:14:19,890
to make it easy, then we have, you know,
250
00:14:19,890 --> 00:14:21,570
a million a year divided by a year,
251
00:14:21,570 --> 00:14:23,673
we have one million times steps, right?
252
00:14:25,890 --> 00:14:28,500
And then for all of those times steps
253
00:14:28,500 --> 00:14:31,170
this one minus l times delta t
254
00:14:31,170 --> 00:14:34,530
is the probability of not leaving.
255
00:14:34,530 --> 00:14:36,810
So all that's left is everything
256
00:14:36,810 --> 00:14:38,985
but the people that have not left in any
257
00:14:38,985 --> 00:14:43,533
of these l divided by delta t times steps.
258
00:14:46,140 --> 00:14:49,560
Cool, cool, cool. Well, what is this?
259
00:14:49,560 --> 00:14:54,560
This is equal to one minus
the exponential of minus lL.
260
00:14:56,070 --> 00:14:59,523
And if this feels like it's
out of nowhere right now,
261
00:15:01,470 --> 00:15:04,950
I'll invite you to watch a
bonus video that I'll be making.
262
00:15:04,950 --> 00:15:06,783
Let me just highlight this.
263
00:15:08,070 --> 00:15:11,070
So there's gonna be a bonus video
264
00:15:11,070 --> 00:15:15,550
on Taylor series and approximation
265
00:15:16,800 --> 00:15:18,090
to explain this.
266
00:15:18,090 --> 00:15:21,780
But really is that when we
have a very small probability,
267
00:15:21,780 --> 00:15:24,270
and we know it's small because delta t
268
00:15:24,270 --> 00:15:29,090
is going to zero here,
we can rewrite that as...
269
00:15:30,780 --> 00:15:33,750
Well, I don't wanna go
through the video right now.
270
00:15:33,750 --> 00:15:34,583
I wanna keep it short.
271
00:15:34,583 --> 00:15:36,400
I've already been talking for a while,
272
00:15:37,350 --> 00:15:38,463
so sorry about that.
273
00:15:39,664 --> 00:15:42,180
It basically involves
the fact that delta t
274
00:15:42,180 --> 00:15:44,670
is gonna be really small so
that we know this is gonna be
275
00:15:44,670 --> 00:15:46,470
like an exponential distribution, okay,
276
00:15:46,470 --> 00:15:47,670
an exponential function.
277
00:15:47,670 --> 00:15:49,173
So we have this one minus,
278
00:15:51,630 --> 00:15:54,030
one minus exponential of minus small l,
279
00:15:54,030 --> 00:15:55,800
the rate times arbitration, okay?
280
00:15:55,800 --> 00:15:58,230
So that's our cumulative
distribution function.
281
00:15:58,230 --> 00:16:00,000
This cumulative distribution function,
282
00:16:00,000 --> 00:16:01,860
it's called cumulative
because it's the sum
283
00:16:01,860 --> 00:16:05,940
of the probability of, I'm
gonna try and highlight here,
284
00:16:05,940 --> 00:16:08,550
of leaving at zero, leaving
it at the first step,
285
00:16:08,550 --> 00:16:09,570
second step, third step.
286
00:16:09,570 --> 00:16:12,270
And you sum them up to ask who has left
287
00:16:12,270 --> 00:16:14,040
at any time before this.
288
00:16:14,040 --> 00:16:16,533
So you're just summing
all of the steps, right?
289
00:16:18,090 --> 00:16:19,773
So in continuous really,
290
00:16:22,184 --> 00:16:25,493
this c of l is the integral
291
00:16:27,390 --> 00:16:31,290
of the probability of
leaving at a time exactly l,
292
00:16:31,290 --> 00:16:34,803
well this is getting
confusing with all the l's.
293
00:16:36,870 --> 00:16:40,413
It's at a time exactly t
overall possible time t.
294
00:16:41,820 --> 00:16:44,430
So the probability that I leave,
295
00:16:44,430 --> 00:16:48,210
and that's what I'm calling
P at a time exactly l
296
00:16:48,210 --> 00:16:52,030
is the derivative of cL
297
00:16:53,640 --> 00:16:57,320
over dL, right?
298
00:16:57,320 --> 00:17:01,020
So if the cumulative is the
sum of all the possibilities
299
00:17:01,020 --> 00:17:03,780
of leaving at all events,
it's the integral,
300
00:17:03,780 --> 00:17:05,940
well to reverse that relationship,
301
00:17:05,940 --> 00:17:08,193
the probability distribution function,
302
00:17:09,510 --> 00:17:12,510
P of L, is simply gonna be the derivative.
303
00:17:12,510 --> 00:17:17,340
Well then the derivative of
this one minus exponential
304
00:17:17,340 --> 00:17:19,770
of minus l times l is is really simple.
305
00:17:19,770 --> 00:17:23,763
It's simply l e the minus lL.
306
00:17:25,620 --> 00:17:28,230
Well you might have seen
those distribution before.
307
00:17:28,230 --> 00:17:32,357
Usually there is simply t or x,
308
00:17:33,810 --> 00:17:35,520
or whatever variable you want.
309
00:17:35,520 --> 00:17:38,940
And this lambda is the rate
of these Poisson process.
310
00:17:38,940 --> 00:17:40,710
This is a Poisson distribution, right?
311
00:17:40,710 --> 00:17:43,620
So it all sort of ties together.
312
00:17:43,620 --> 00:17:46,080
We know that the average
is one over lambda.
313
00:17:46,080 --> 00:17:47,760
So the average time that it takes to leave
314
00:17:47,760 --> 00:17:50,100
is one over l in this case, right?
315
00:17:50,100 --> 00:17:55,100
So if your rate at which
you leave is 0.1 per week,
316
00:17:55,200 --> 00:17:57,510
we know that it's gonna
take you on average 10 weeks
317
00:17:57,510 --> 00:17:59,523
to leave the cloning factory, right?
318
00:18:00,810 --> 00:18:02,433
Very mysterious building.
319
00:18:04,440 --> 00:18:08,400
Okay, well, so now we're curious
about competing processes.
320
00:18:08,400 --> 00:18:10,120
So what is the probability
321
00:18:15,810 --> 00:18:20,810
of cloning before leaving?
322
00:18:25,560 --> 00:18:29,610
Well, what we're gonna
wanna do is integrate
323
00:18:29,610 --> 00:18:34,023
over the probability of
leaving at time exactly l.
324
00:18:37,050 --> 00:18:40,200
And then if I know that
I'm leaving at time l,
325
00:18:40,200 --> 00:18:43,110
I wanna ask what's the probability
that I've cloned myself
326
00:18:43,110 --> 00:18:45,063
in a time less than l.
327
00:18:47,580 --> 00:18:50,430
Well this probability of
cloning myself is gonna be
328
00:18:50,430 --> 00:18:52,920
the same cumulative distribution here,
329
00:18:52,920 --> 00:18:54,810
it's gonna be the same as this
330
00:18:54,810 --> 00:18:57,993
but with a rate c instead of l, right?
331
00:18:59,160 --> 00:19:04,160
So it's gonna be one minus e
332
00:19:04,740 --> 00:19:08,970
to the minus cL is the probability
that I've cloned myself
333
00:19:08,970 --> 00:19:11,320
before l, so it's this
cumulative distribution.
334
00:19:13,470 --> 00:19:15,780
And then I'm just integrating those
335
00:19:15,780 --> 00:19:18,180
over all possible times to l.
336
00:19:18,180 --> 00:19:20,640
All right, I'm running out
space here, let me switch.
337
00:19:20,640 --> 00:19:24,160
So very quickly, my
probability I was integrating
338
00:19:25,980 --> 00:19:29,400
from zero to infinity, the
probability that I leave
339
00:19:29,400 --> 00:19:32,370
at time l which is a Poisson distribution,
340
00:19:32,370 --> 00:19:35,193
I can write that from memory.
341
00:19:36,750 --> 00:19:39,330
And then the probability
that I've cloned myself
342
00:19:39,330 --> 00:19:44,103
before this time l you
said is one minus e cL.
343
00:19:48,150 --> 00:19:48,983
Okay.
344
00:19:53,850 --> 00:19:58,850
So if you draw on your own calculus days,
345
00:20:03,600 --> 00:20:08,073
you just like split up this
integral into two terms.
346
00:20:12,840 --> 00:20:17,310
And now we have this
fun sum of rates here,
347
00:20:17,310 --> 00:20:21,993
c plus l when I do the product
of my two exponential terms.
348
00:20:24,570 --> 00:20:25,403
Okay?
349
00:20:27,330 --> 00:20:31,260
Well this one is an easy integral
350
00:20:31,260 --> 00:20:33,360
if you remember all your rules.
351
00:20:33,360 --> 00:20:36,630
So that that's simply, you
know, this l e minus lL
352
00:20:36,630 --> 00:20:41,630
is really the derivative
of the exponential
353
00:20:42,780 --> 00:20:47,010
minus lL and it's minus that, right?
354
00:20:47,010 --> 00:20:50,823
And I'm evaluating it
at infinity and at zero.
355
00:20:54,030 --> 00:20:56,493
So from this I'm just gonna get,
356
00:20:58,770 --> 00:21:02,223
it's minus zero minus
minus one, so it's one.
357
00:21:04,710 --> 00:21:09,710
Okay, this one is gonna
give me l over c plus l.
358
00:21:09,990 --> 00:21:12,723
I'm just taking the
integral of the exponential.
359
00:21:18,060 --> 00:21:21,450
And I'm, again, evaluating,
this is my notation by the way,
360
00:21:21,450 --> 00:21:23,430
for like evaluating at l equal infinity.
361
00:21:23,430 --> 00:21:26,763
Those are my boundaries
on my definite integral.
362
00:21:28,500 --> 00:21:30,200
So this one is just gonna give me,
363
00:21:33,510 --> 00:21:36,423
just gonna give me l over c plus l.
364
00:21:37,380 --> 00:21:41,970
So I have one minus l over c plus l.
365
00:21:41,970 --> 00:21:44,190
I'm just gonna put that
on the same denominator,
366
00:21:44,190 --> 00:21:48,363
so I get c plus l minus l over c plus l.
367
00:21:50,970 --> 00:21:55,113
And then I get c over c plus l.
368
00:21:57,660 --> 00:21:59,910
Okay, well you might have a little bit,
369
00:21:59,910 --> 00:22:02,820
you might either be bored,
or if you followed it all,
370
00:22:02,820 --> 00:22:06,330
you might have a little bit
of a eureka moment here.
371
00:22:06,330 --> 00:22:08,133
Let me, like, erase some of this.
372
00:22:10,650 --> 00:22:11,973
What is this really?
373
00:22:14,220 --> 00:22:18,990
Well, when we took the product here
374
00:22:18,990 --> 00:22:23,990
of two of our Poisson processes,
375
00:22:24,900 --> 00:22:28,290
well, we just learned
something here with this one,
376
00:22:28,290 --> 00:22:33,290
is that the rate
377
00:22:35,880 --> 00:22:37,060
of a sum
378
00:22:41,435 --> 00:22:43,102
of Poisson processes
379
00:22:47,250 --> 00:22:51,750
is the sum of the rates.
380
00:22:51,750 --> 00:22:54,290
Well really a sum of
Poisson processes is a,
381
00:22:58,364 --> 00:23:00,930
is simply, I mean, is a Poisson process
382
00:23:00,930 --> 00:23:02,583
with the sum of the rates.
383
00:23:04,170 --> 00:23:07,440
Okay, so that's interesting.
So now what is this saying?
384
00:23:07,440 --> 00:23:10,320
Is saying that one way
to do our previous code
385
00:23:10,320 --> 00:23:12,427
is not to go over everyone and ask,
386
00:23:12,427 --> 00:23:16,320
"Do you leave, do you clone yourself?"
387
00:23:16,320 --> 00:23:18,600
We can combine those two Poisson process
388
00:23:18,600 --> 00:23:21,690
and ask every person,
"Do you do something?"
389
00:23:21,690 --> 00:23:24,483
And doing something
happens at a rate c plus l.
390
00:23:25,890 --> 00:23:29,730
Okay, and then when they do something,
391
00:23:29,730 --> 00:23:31,890
we can ask, "Well, what's the probability
392
00:23:31,890 --> 00:23:34,767
that this something was a cloning event?"
393
00:23:36,960 --> 00:23:41,200
Well, the probability
394
00:23:45,750 --> 00:23:48,280
of Poisson process,
395
00:23:51,300 --> 00:23:53,220
and I'm kind of gonna call it lambda one.
396
00:23:53,220 --> 00:23:55,450
So a Poisson process which rate lambda one
397
00:23:57,300 --> 00:24:00,543
occurring, and there's
probably gonna be a typo here.
398
00:24:01,380 --> 00:24:03,300
I apologize,
399
00:24:03,300 --> 00:24:08,300
before a Poisson process
400
00:24:09,180 --> 00:24:11,080
with a rate lambda two
401
00:24:13,500 --> 00:24:16,650
is simply gonna be lambda one over the sum
402
00:24:16,650 --> 00:24:18,663
of lambda one plus lambda two.
403
00:24:21,270 --> 00:24:24,150
That's what we calculated really.
404
00:24:24,150 --> 00:24:27,120
And this is an incredibly useful result.
405
00:24:27,120 --> 00:24:30,270
I use it, you know, all
the time in actual paper.
406
00:24:30,270 --> 00:24:31,980
One way to think about this is, you know,
407
00:24:31,980 --> 00:24:36,033
imagine you're a grad
student, you're in Burlington,
408
00:24:36,900 --> 00:24:40,920
your parents are far away,
and they all call you.
409
00:24:40,920 --> 00:24:43,650
Let's say that your mom calls
you on average once a week
410
00:24:43,650 --> 00:24:46,323
and your dad calls you
on average twice a week.
411
00:24:47,460 --> 00:24:51,090
Well that means you get three
phone calls a week, right?
412
00:24:51,090 --> 00:24:53,430
So this is this conclusion in blue,
413
00:24:53,430 --> 00:24:55,320
the rate of a sum of Poisson processes
414
00:24:55,320 --> 00:24:57,150
is the sum of the rates.
415
00:24:57,150 --> 00:25:00,450
So if you have one phone
call from your mom a week,
416
00:25:00,450 --> 00:25:03,840
two from your dad a week, you
get three phone calls a week.
417
00:25:03,840 --> 00:25:07,830
Easy. Now, let's say that
right now your phone rings.
418
00:25:07,830 --> 00:25:11,520
What's the probability
that it's your dad, right?
419
00:25:11,520 --> 00:25:14,880
Well he calls, like,
two out of three calls,
420
00:25:14,880 --> 00:25:16,227
he calls twice a week,
421
00:25:16,227 --> 00:25:19,020
and you get three phone calls a week.
422
00:25:19,020 --> 00:25:21,660
So two out of three
calls are from your dad.
423
00:25:21,660 --> 00:25:24,180
So it's this two over two plus one.
424
00:25:24,180 --> 00:25:25,130
It's just this 2/3.
425
00:25:27,060 --> 00:25:30,000
It's not a crazy result,
but it's super useful,
426
00:25:30,000 --> 00:25:32,580
because if we go back, let me see,
427
00:25:32,580 --> 00:25:35,100
do I have our old code here?
428
00:25:35,100 --> 00:25:37,470
So this is from the previous video.
429
00:25:37,470 --> 00:25:42,150
Really we could replace this entire block,
430
00:25:42,150 --> 00:25:44,700
we could draw less random numbers here.
431
00:25:44,700 --> 00:25:47,463
Now order doesn't matter
'cause we're fixing that.
432
00:25:48,660 --> 00:25:50,190
We've renormalize our rates,
433
00:25:50,190 --> 00:25:52,740
so we don't have to
worry about all of this.
434
00:25:52,740 --> 00:25:56,853
So we have our clone factory
and our different rates.
435
00:25:57,900 --> 00:26:01,323
Now, when we go over people,
we're just gonna ask,
436
00:26:02,287 --> 00:26:04,320
"Is this person doing something," right?
437
00:26:04,320 --> 00:26:06,633
So I'm drawing one random number.
438
00:26:09,420 --> 00:26:11,260
This person is doing something
439
00:26:12,390 --> 00:26:15,030
at a rate c if it clones itself,
440
00:26:15,030 --> 00:26:17,940
l if it leaves, or c plus l delta t.
441
00:26:17,940 --> 00:26:19,803
That's my sum of Poisson process.
442
00:26:20,970 --> 00:26:23,220
Okay, I have this now.
443
00:26:23,220 --> 00:26:25,560
Now let's say they choose to do something,
444
00:26:25,560 --> 00:26:27,363
well, with probability,
445
00:26:30,840 --> 00:26:35,840
so with probability c over c plus l,
446
00:26:37,230 --> 00:26:38,283
it's a cloning event.
447
00:26:39,540 --> 00:26:44,163
So now, oh, this is a different sheet.
448
00:26:48,750 --> 00:26:52,110
So we say we add N of t as our variable.
449
00:26:52,110 --> 00:26:53,977
I got confused here. Oops.
450
00:26:53,977 --> 00:26:55,353
And ft.
451
00:26:56,250 --> 00:26:58,683
We go over people equal one.
452
00:27:00,660 --> 00:27:03,450
And this doesn't matter that
much, but, okay, N of t.
453
00:27:03,450 --> 00:27:06,993
So it's a cloning event, so N
of t goes to N of t plus one.
454
00:27:08,550 --> 00:27:12,240
And else, it's a leaving event, right?
455
00:27:12,240 --> 00:27:16,620
So N of t goes to N of t minus one.
456
00:27:16,620 --> 00:27:19,260
And now there's no more problem of which,
457
00:27:19,260 --> 00:27:21,570
are you cloning yourself at the
same time as you're leaving?
458
00:27:21,570 --> 00:27:22,500
There's none of this now.
459
00:27:22,500 --> 00:27:25,200
We've sort of fixed this
by using this property
460
00:27:25,200 --> 00:27:28,680
that a sum of Poisson
processes is a Poisson process,
461
00:27:28,680 --> 00:27:31,170
and then dealing with it
with our probabilities
462
00:27:31,170 --> 00:27:32,220
for each event.
463
00:27:32,220 --> 00:27:35,160
So that's it for this video.
464
00:27:35,160 --> 00:27:37,590
There's a lot more tricks that are gonna,
465
00:27:37,590 --> 00:27:39,450
or other problems that are gonna pop up.
466
00:27:39,450 --> 00:27:41,580
But these like are the key things
467
00:27:41,580 --> 00:27:45,630
that you have to think
about, order of operation,
468
00:27:45,630 --> 00:27:48,960
of different mechanism and
the scale of different rates.
469
00:27:48,960 --> 00:27:51,340
And the key mathematical tricks are
470
00:27:52,500 --> 00:27:54,750
this convergence of Poisson processes
471
00:27:54,750 --> 00:27:57,510
when you discretize with very small steps,
472
00:27:57,510 --> 00:28:00,390
and the fact that you can
deal with competing processes
473
00:28:00,390 --> 00:28:02,993
as a sum of Poisson processes.
474
00:28:02,993 --> 00:28:05,443
So that really goes to
the like mathematical core
475
00:28:06,479 --> 00:28:08,820
of these compartmental models,
476
00:28:08,820 --> 00:28:12,243
these simple flows of
density and all that.
477
00:28:13,110 --> 00:28:14,280
So I really like this.
478
00:28:14,280 --> 00:28:16,470
If you want to talk more
about how to implement them
479
00:28:16,470 --> 00:28:17,970
or how to do math around this,
480
00:28:17,970 --> 00:28:21,300
we can use some of our
discussion time to go over it.
481
00:28:21,300 --> 00:28:23,500
But otherwise, I'll see
you in the next one.