1 00:00:02,490 --> 00:00:04,410 Obviously we're in my office again, 2 00:00:04,410 --> 00:00:05,850 which often means that we'll be 3 00:00:05,850 --> 00:00:08,340 doing some coding in the video. 4 00:00:08,340 --> 00:00:09,240 And in this case, 5 00:00:09,240 --> 00:00:11,040 I wanna show you codes that implement 6 00:00:11,040 --> 00:00:14,070 the really simple, stochastic CA 7 00:00:14,070 --> 00:00:15,330 that we saw in the last one. 8 00:00:15,330 --> 00:00:17,613 So random walks and percolation. 9 00:00:19,260 --> 00:00:22,530 And I keep showing different modeling schemes 10 00:00:22,530 --> 00:00:23,910 and sharing MATLAB codes, 11 00:00:23,910 --> 00:00:26,220 C++ code and Python. 12 00:00:26,220 --> 00:00:28,230 Here I wanted to use Google Colab 13 00:00:28,230 --> 00:00:29,580 specifically for this one 14 00:00:29,580 --> 00:00:32,520 because we'll see some interesting interactive features, 15 00:00:32,520 --> 00:00:34,140 that if you've never played with 16 00:00:34,140 --> 00:00:36,450 are actually really easy 17 00:00:36,450 --> 00:00:39,510 to use in Google Colab. 18 00:00:39,510 --> 00:00:40,990 So we're gonna start with 19 00:00:42,660 --> 00:00:45,480 what is probably the slightly more complicated 20 00:00:45,480 --> 00:00:47,070 model of the two we saw. 21 00:00:47,070 --> 00:00:48,423 The random walker. 22 00:00:49,680 --> 00:00:53,613 And I'll start with a function to run a random walker. 23 00:00:57,270 --> 00:01:00,000 And essentially I'm gonna assume that I have a world, 24 00:01:00,000 --> 00:01:01,500 I'm calling this a world to be fancy, 25 00:01:01,500 --> 00:01:03,240 but it's my two dimensional grid. 26 00:01:03,240 --> 00:01:04,350 So a big matrix, 27 00:01:04,350 --> 00:01:06,940 or in this case a two dimensional array 28 00:01:08,670 --> 00:01:09,990 that can be square or not. 29 00:01:09,990 --> 00:01:12,390 So that array is gonna have some specific dimensions 30 00:01:12,390 --> 00:01:14,430 N one and N two. 31 00:01:14,430 --> 00:01:16,680 I'm gonna keep track of my random locker. 32 00:01:16,680 --> 00:01:20,523 So IJ is where my random locker is at any time. 33 00:01:24,870 --> 00:01:27,240 And here I'm doing something kind of fancy. 34 00:01:27,240 --> 00:01:29,250 So I keep track of my position. 35 00:01:29,250 --> 00:01:31,980 I'm gonna keep track of the history of my random walker 36 00:01:31,980 --> 00:01:33,840 so it's entire trajectory in time. 37 00:01:33,840 --> 00:01:35,670 So that's a dynamical system. 38 00:01:35,670 --> 00:01:37,530 And I'm going to evolve or grow, 39 00:01:37,530 --> 00:01:41,730 or let that random walker move for a fixed number of steps. 40 00:01:41,730 --> 00:01:45,690 50,000 or whatever integer I'd want to use. 41 00:01:45,690 --> 00:01:47,460 So for every step, 42 00:01:47,460 --> 00:01:51,510 I'm gonna do this slightly fancy thing where 43 00:01:51,510 --> 00:01:54,690 even though my model is specified over binary state, 44 00:01:54,690 --> 00:01:56,850 zero if the cell is unoccupied, 45 00:01:56,850 --> 00:01:58,800 one if the walker's there, 46 00:01:58,800 --> 00:02:01,980 I'm gonna set cells that have been visited 47 00:02:01,980 --> 00:02:04,020 at any time, maybe multiple times, 48 00:02:04,020 --> 00:02:07,410 but if a cell was visited at least once, 49 00:02:07,410 --> 00:02:10,380 I'll set a state to two thirds. 50 00:02:10,380 --> 00:02:13,290 This is not formally in the model, it's for visualization. 51 00:02:13,290 --> 00:02:16,020 To be able to see not where the random walker is, 52 00:02:16,020 --> 00:02:19,173 or only where it is, but where it has been, right? 53 00:02:20,610 --> 00:02:23,760 And so I have disposition IJ for my random walker. 54 00:02:23,760 --> 00:02:26,220 I guess I didn't need this line here. 55 00:02:26,220 --> 00:02:28,017 But I keep my position IJ. 56 00:02:28,017 --> 00:02:31,320 And I'm gonna throw a random number, a random die, 57 00:02:31,320 --> 00:02:33,510 random coin that's gonna give me 58 00:02:33,510 --> 00:02:36,360 a continuous number between zero and one. 59 00:02:36,360 --> 00:02:39,300 That's so I can pick one of my four different rule set. 60 00:02:39,300 --> 00:02:41,100 We saw some very similar algorithms 61 00:02:41,100 --> 00:02:43,110 when we're looking at discrete models, 62 00:02:43,110 --> 00:02:45,150 like the cloning factory. 63 00:02:45,150 --> 00:02:46,860 And so the way this works is, 64 00:02:46,860 --> 00:02:49,530 if my random number gives me 65 00:02:49,530 --> 00:02:53,040 something smaller than 25 percent, 66 00:02:53,040 --> 00:02:55,320 I can accept my first option. 67 00:02:55,320 --> 00:02:57,063 It's just to take a right step. 68 00:02:58,410 --> 00:03:01,710 And I realize now that in the last video, 69 00:03:01,710 --> 00:03:02,543 you know I've 70 00:03:03,600 --> 00:03:07,350 conceptually or mathematically formulated random walk 71 00:03:07,350 --> 00:03:09,780 but I forgot to talk about boundary conditions. 72 00:03:09,780 --> 00:03:12,270 Whenever it's time to code these things, 73 00:03:12,270 --> 00:03:14,220 you need to think about boundary conditions 74 00:03:14,220 --> 00:03:17,130 because of, of course your world isn't infinite. 75 00:03:17,130 --> 00:03:20,040 So much like we did last week in the elementary CA, 76 00:03:20,040 --> 00:03:22,620 I'll just assume periodic boundary conditions 77 00:03:22,620 --> 00:03:25,173 using this modular operation. 78 00:03:26,220 --> 00:03:27,900 So I take a right step, 79 00:03:27,900 --> 00:03:29,850 which brings me to J plus one 80 00:03:29,850 --> 00:03:31,380 or to the other side of the world 81 00:03:31,380 --> 00:03:34,713 if J plus one is outside of the bounds of the world. 82 00:03:35,670 --> 00:03:39,270 If my random number was not below 83 00:03:39,270 --> 00:03:40,830 0.25, 84 00:03:40,830 --> 00:03:44,100 I'll have another probability that if it's below 0.5, 85 00:03:44,100 --> 00:03:46,980 so now I would know because of this else if. 86 00:03:46,980 --> 00:03:49,830 I would know that it was between 25 and 50, 87 00:03:49,830 --> 00:03:53,310 which also occurs with probability 25 percent. 88 00:03:53,310 --> 00:03:56,610 And so if it is between 25 and 50, 89 00:03:56,610 --> 00:03:59,790 I take my second option which is to go to the bottom, 90 00:03:59,790 --> 00:04:01,680 which brings me to I minus one 91 00:04:01,680 --> 00:04:03,780 with the module to give me the freedom 92 00:04:03,780 --> 00:04:06,900 to loop around the world, and so on and so forth. 93 00:04:06,900 --> 00:04:10,110 So if it's above 0.5 but below 75, 94 00:04:10,110 --> 00:04:12,540 which happens with probability 25 percent, 95 00:04:12,540 --> 00:04:14,880 I take my left step to J minus one 96 00:04:14,880 --> 00:04:19,590 with the module of else between 75 and 100 percent. 97 00:04:19,590 --> 00:04:21,750 I do my top step to I plus one 98 00:04:21,750 --> 00:04:24,660 with the module of to loop around the world. 99 00:04:24,660 --> 00:04:26,430 I could do a biased random walk. 100 00:04:26,430 --> 00:04:29,130 Those probabilities don't have to be fixed. 101 00:04:29,130 --> 00:04:31,170 So if I had only a 10 percent chance, 102 00:04:31,170 --> 00:04:34,410 let's say I'm going left and a 40 percent chance of go, 103 00:04:34,410 --> 00:04:36,150 10 chance of going right 104 00:04:36,150 --> 00:04:38,640 and a 40 percent chance of going to the bottom, 105 00:04:38,640 --> 00:04:40,770 this would stay at 0.5 106 00:04:40,770 --> 00:04:43,113 and this one would go to 0.1. 107 00:04:43,950 --> 00:04:46,710 So these could be parameters of my random walk 108 00:04:46,710 --> 00:04:48,270 but I wanna show you the simplest case 109 00:04:48,270 --> 00:04:50,460 of the unbiased random walk. 110 00:04:50,460 --> 00:04:52,173 And then I set my, 111 00:04:53,160 --> 00:04:55,320 the cell at this position to one 112 00:04:55,320 --> 00:04:57,750 to show that that's where the 113 00:04:57,750 --> 00:04:59,640 random walker currently is. 114 00:04:59,640 --> 00:05:02,700 And I append or add the current position 115 00:05:02,700 --> 00:05:05,283 of that random walker in the history of the world. 116 00:05:07,290 --> 00:05:09,090 And now I have a function to run this 117 00:05:09,090 --> 00:05:10,950 and plug the state of the system. 118 00:05:10,950 --> 00:05:14,220 So I define the size of my world. 119 00:05:14,220 --> 00:05:16,710 Right now I'm asking for 120 00:05:16,710 --> 00:05:18,660 50,000 steps 121 00:05:18,660 --> 00:05:22,170 and I also have this DT parameter, which is for my plot. 122 00:05:22,170 --> 00:05:25,890 I can track in time the growth of my 123 00:05:25,890 --> 00:05:27,480 or the 124 00:05:27,480 --> 00:05:29,040 walk of my random walker. 125 00:05:29,040 --> 00:05:32,070 If I had a one, I would be following every single step. 126 00:05:32,070 --> 00:05:33,510 Plotting every single step of the way 127 00:05:33,510 --> 00:05:36,090 much like we did in the CA case, 128 00:05:36,090 --> 00:05:38,310 elementary CA video. 129 00:05:38,310 --> 00:05:40,760 But here, I'll just plot the final stake for now. 130 00:05:41,670 --> 00:05:44,850 I initialized my world with a bunch of zeros 131 00:05:44,850 --> 00:05:46,200 so nothing's occupied. 132 00:05:46,200 --> 00:05:48,300 My random walker can go anywhere. 133 00:05:48,300 --> 00:05:51,990 And then I put my random walker in the middle of that world, 134 00:05:51,990 --> 00:05:53,610 in the middle of nowhere. 135 00:05:53,610 --> 00:05:55,443 And I start with an empty history. 136 00:05:57,150 --> 00:06:00,150 And so this is much like we did last time. 137 00:06:00,150 --> 00:06:01,740 I could plug through time 138 00:06:01,740 --> 00:06:04,863 but here I'm just gonna plug the final state of my system. 139 00:06:06,210 --> 00:06:09,300 So it's already a surprisingly beautiful figure, right? 140 00:06:09,300 --> 00:06:12,600 So my random water started right in the middle of nowhere, 141 00:06:12,600 --> 00:06:14,310 in the middle of this figure, 142 00:06:14,310 --> 00:06:16,050 and then randomly went up 143 00:06:16,050 --> 00:06:18,000 and explored this like 144 00:06:18,000 --> 00:06:21,150 cool looking cluster of spaces. 145 00:06:21,150 --> 00:06:24,360 And like I said, I could decide to 146 00:06:24,360 --> 00:06:28,260 plug where my random walker has been every 10 steps. 147 00:06:28,260 --> 00:06:30,240 In which case I'll just have this like 148 00:06:30,240 --> 00:06:32,160 annoyingly slow video. 149 00:06:32,160 --> 00:06:33,870 I guess I didn't have to like 150 00:06:33,870 --> 00:06:36,960 enforce a sleep function here to make it even slower, 151 00:06:36,960 --> 00:06:39,420 but I could track my random walker in real time 152 00:06:39,420 --> 00:06:42,573 and look at the evolution or the growth of that cluster. 153 00:06:43,680 --> 00:06:45,210 In class, in discussion group, 154 00:06:45,210 --> 00:06:46,780 we'll be looking at the 155 00:06:47,640 --> 00:06:51,153 mathematical properties of the dynamics of the random walk. 156 00:06:52,230 --> 00:06:53,730 But I think what's interesting 157 00:06:56,490 --> 00:06:59,070 with these spatially explicit model 158 00:06:59,070 --> 00:07:00,040 is to look 159 00:07:01,290 --> 00:07:02,373 at space itself. 160 00:07:03,270 --> 00:07:05,460 Right, those clusters are beautiful. 161 00:07:05,460 --> 00:07:07,470 This one looks like a trail of smoke 162 00:07:07,470 --> 00:07:10,080 and you see the periodic boundaries acting up here. 163 00:07:10,080 --> 00:07:14,283 So both left and right to left, and top to bottom. 164 00:07:16,050 --> 00:07:17,040 Well you tend to get just 165 00:07:17,040 --> 00:07:19,290 beautiful clusters out of these. 166 00:07:19,290 --> 00:07:21,810 And it brings up notions that we saw last week. 167 00:07:21,810 --> 00:07:25,920 So fractality, the dimensionality of these clusters 168 00:07:25,920 --> 00:07:28,860 might be an interesting thing to look at. 169 00:07:28,860 --> 00:07:31,323 Here I look at how we can coarse grain them. 170 00:07:32,340 --> 00:07:33,480 And so here I'm gonna say, 171 00:07:33,480 --> 00:07:37,680 I'm gonna coarse grain my states by 200. 172 00:07:37,680 --> 00:07:41,340 So what I'm meaning is here's my position in X and Y. 173 00:07:41,340 --> 00:07:44,613 So this is the same cluster as we had here if I rerun it. 174 00:07:45,600 --> 00:07:47,730 All right, so this is exactly the same cluster. 175 00:07:47,730 --> 00:07:50,350 We notice a little hole in this 176 00:07:51,300 --> 00:07:52,133 shape. 177 00:07:52,980 --> 00:07:56,940 This looks like continents on a different planet somehow. 178 00:07:56,940 --> 00:08:00,360 And in the middle panel what we have 179 00:08:00,360 --> 00:08:01,320 is every 180 00:08:01,320 --> 00:08:02,670 200th 181 00:08:02,670 --> 00:08:04,020 state of that 182 00:08:04,020 --> 00:08:05,130 random walk. 183 00:08:05,130 --> 00:08:06,810 Right, so we're just sampling 184 00:08:06,810 --> 00:08:10,470 at every time, at every delta T equals 200, 185 00:08:10,470 --> 00:08:12,210 the state of our random walker. 186 00:08:12,210 --> 00:08:15,750 And we capture much of the shape of this random walk. 187 00:08:15,750 --> 00:08:18,663 Because the random walks is so random, so slow, 188 00:08:19,560 --> 00:08:21,870 it tends to spend a lot of time in the same place. 189 00:08:21,870 --> 00:08:23,160 So it's easy to course grain it 190 00:08:23,160 --> 00:08:27,723 and still keep the large scale feature of the random walk. 191 00:08:28,920 --> 00:08:30,480 And then the final panel, 192 00:08:30,480 --> 00:08:35,073 what I show is the first 200 step of my random walk. 193 00:08:38,670 --> 00:08:41,700 Right, and I coarse grain even more. 194 00:08:41,700 --> 00:08:45,243 And then eventually like run out of steps. 195 00:08:54,990 --> 00:08:58,950 I just realized I don't show the first 200 or 1000 step, 196 00:08:58,950 --> 00:09:01,440 I'm sorry, I should have made that clearer. 197 00:09:01,440 --> 00:09:05,580 What I show is a sampling with the same number of points. 198 00:09:05,580 --> 00:09:07,843 So I had 50,000 199 00:09:08,760 --> 00:09:09,900 steps on the left, 200 00:09:09,900 --> 00:09:12,750 so that means that I have 50 samples 201 00:09:12,750 --> 00:09:14,670 at intervals of 1000 202 00:09:14,670 --> 00:09:17,523 and therefore here I plug the first 50 times steps. 203 00:09:21,325 --> 00:09:23,027 And so if I coarse grain in less 204 00:09:24,060 --> 00:09:26,103 I get more points here and there. 205 00:09:27,000 --> 00:09:30,360 What's interesting is that if you run more of these 206 00:09:30,360 --> 00:09:33,000 there is this notion of self similarity. 207 00:09:33,000 --> 00:09:34,830 You know, I mentioned that the dimension 208 00:09:34,830 --> 00:09:37,020 of these clusters might be interesting. 209 00:09:37,020 --> 00:09:40,900 And it's not unsurprising to get to get similar clusters 210 00:09:41,850 --> 00:09:45,270 or similar looking shapes on the right and the left, right? 211 00:09:45,270 --> 00:09:47,490 Even though this is just, you know, 212 00:09:47,490 --> 00:09:51,840 the first 10 percent or something of the full clusters. 213 00:09:51,840 --> 00:09:55,290 The features tend to repeat this themselves at all scales. 214 00:09:55,290 --> 00:09:57,420 And by features I mean both the visual 215 00:09:57,420 --> 00:10:00,420 features of the graph itself 216 00:10:00,420 --> 00:10:02,820 with the statistical features of the random walk. 217 00:10:02,820 --> 00:10:05,760 And we're gonna explore that more mathematically. 218 00:10:05,760 --> 00:10:08,760 So it's yet another example of how, 219 00:10:08,760 --> 00:10:11,880 you know, complex natural looking patterns 220 00:10:11,880 --> 00:10:14,340 can emerge from very simple rules. 221 00:10:14,340 --> 00:10:16,353 Here are just random motion, right? 222 00:10:17,700 --> 00:10:20,070 And we're gonna see that in percolation as well. 223 00:10:20,070 --> 00:10:21,210 So I'll be sharing these codes 224 00:10:21,210 --> 00:10:22,980 and I invite you to play with them. 225 00:10:22,980 --> 00:10:26,550 Maybe make a biased random walk or, 226 00:10:26,550 --> 00:10:29,733 or start looking at the dimensionally of these clusters. 227 00:10:30,810 --> 00:10:32,460 The codes are fairly simple. 228 00:10:32,460 --> 00:10:35,280 So in this one I'll be doing something a little fancier 229 00:10:35,280 --> 00:10:37,740 to introduce this notion of interactive 230 00:10:37,740 --> 00:10:39,183 component in the model. 231 00:10:40,410 --> 00:10:42,810 And so percolation is this really simple model. 232 00:10:42,810 --> 00:10:44,310 I said in the first video, 233 00:10:44,310 --> 00:10:46,950 we usually just don't even run it in time, 234 00:10:46,950 --> 00:10:48,630 we just run it once. 235 00:10:48,630 --> 00:10:53,630 So upsell can become occupied with a fixed probability. 236 00:10:54,030 --> 00:10:55,380 So I have again, my world, 237 00:10:55,380 --> 00:10:58,320 which I assume is gonna be full of zeroes at the start. 238 00:10:58,320 --> 00:11:00,960 And I'm gonna go over every cell in that grid. 239 00:11:00,960 --> 00:11:03,360 So for every cell in every row and every column. 240 00:11:05,100 --> 00:11:07,020 And I'm gonna throw a random number. 241 00:11:07,020 --> 00:11:08,940 So a random die or coin 242 00:11:08,940 --> 00:11:11,700 that's gonna give me a number between zero and one, 243 00:11:11,700 --> 00:11:13,353 which would form probability. 244 00:11:14,400 --> 00:11:19,400 And if that number is below my occupation probability P, 245 00:11:20,190 --> 00:11:22,710 so this probability I'm gonna turn cell on. 246 00:11:22,710 --> 00:11:25,500 If not, I'm gonna leave it off at zero. 247 00:11:25,500 --> 00:11:28,590 In percolation we often call this occupied 248 00:11:28,590 --> 00:11:30,150 if it's active at one 249 00:11:30,150 --> 00:11:33,270 and unoccupied if it remains at zero. 250 00:11:33,270 --> 00:11:35,040 And then we might be interested in 251 00:11:35,040 --> 00:11:38,130 whether there's a cluster that can conduct current, 252 00:11:38,130 --> 00:11:40,650 right, percolation could be a model for 253 00:11:40,650 --> 00:11:43,800 spread of electricity in a damaged material, 254 00:11:43,800 --> 00:11:44,700 things like that. 255 00:11:44,700 --> 00:11:46,680 We're often interested in the connectivity 256 00:11:46,680 --> 00:11:48,273 and shape of these clusters. 257 00:11:52,770 --> 00:11:54,750 And this next function is introducing 258 00:11:54,750 --> 00:11:59,610 this really simple tool called forms on Google Colab. 259 00:11:59,610 --> 00:12:02,490 And so I'm gonna have a probability, 260 00:12:02,490 --> 00:12:05,430 which is my parameter in this percolation model, 261 00:12:05,430 --> 00:12:07,830 which I could set to a fixed value 262 00:12:07,830 --> 00:12:11,370 or I could tell Google Colab with this line here 263 00:12:11,370 --> 00:12:15,480 that I want this parameter to be of a type slider 264 00:12:15,480 --> 00:12:18,900 between zero and one with steps of 0.01. 265 00:12:18,900 --> 00:12:20,610 Just adding this line, 266 00:12:20,610 --> 00:12:21,443 if you add it, 267 00:12:21,443 --> 00:12:23,340 magically you'll get this slider on the right. 268 00:12:23,340 --> 00:12:26,160 And you'll notice that if I move this slider around 269 00:12:26,160 --> 00:12:29,373 I'm updating the probability in the code itself. 270 00:12:30,510 --> 00:12:32,640 You'll also notice that when I move it 271 00:12:32,640 --> 00:12:34,440 the cells run automatically. 272 00:12:34,440 --> 00:12:36,240 That's because at the very beginning 273 00:12:36,240 --> 00:12:38,880 I added this other comment 274 00:12:38,880 --> 00:12:40,890 to tell the cell to run automatically 275 00:12:40,890 --> 00:12:43,530 when there is a change in the Google form, all right? 276 00:12:43,530 --> 00:12:45,030 The Google form could be text, 277 00:12:45,030 --> 00:12:46,590 could be, there are a lot of like 278 00:12:46,590 --> 00:12:48,120 different data types to play with 279 00:12:48,120 --> 00:12:50,050 and I invite you to like Google 280 00:12:51,090 --> 00:12:52,230 how to play with them 281 00:12:52,230 --> 00:12:54,423 if you're interested in more interactivity. 282 00:12:55,920 --> 00:12:57,990 So that's how we're gonna set the value 283 00:12:57,990 --> 00:13:00,840 of our percolation probability. 284 00:13:00,840 --> 00:13:02,250 Our world, like I said, 285 00:13:02,250 --> 00:13:05,610 is gonna start in with simple initial conditions, 286 00:13:05,610 --> 00:13:07,980 all zeros, everything unoccupied. 287 00:13:07,980 --> 00:13:09,450 And we're gonna run percolation, 288 00:13:09,450 --> 00:13:11,730 which means that a fraction probability, 289 00:13:11,730 --> 00:13:14,760 fraction P of our sites are gonna 290 00:13:14,760 --> 00:13:16,800 turn on and become occupied. 291 00:13:16,800 --> 00:13:18,900 And then we're gonna plug two figures. 292 00:13:18,900 --> 00:13:20,910 The first one will be the state 293 00:13:20,910 --> 00:13:23,520 of the world after percolation, 294 00:13:23,520 --> 00:13:25,770 which should look like white noise 295 00:13:25,770 --> 00:13:29,370 with a fraction probability of white cells 296 00:13:29,370 --> 00:13:32,133 and one minus probability of black cells. 297 00:13:33,150 --> 00:13:35,100 And I'm gonna do something fancier here 298 00:13:35,100 --> 00:13:36,990 that I'm not gonna explain too much, 299 00:13:36,990 --> 00:13:39,240 but I'm gonna look for connected cluster 300 00:13:39,240 --> 00:13:41,430 in my Von Neumann Neighborhood. 301 00:13:41,430 --> 00:13:43,650 So here this structure array 302 00:13:43,650 --> 00:13:46,170 is encoding what I define as a connection. 303 00:13:46,170 --> 00:13:49,080 So I explicitly say that diagonals, 304 00:13:49,080 --> 00:13:52,260 the two top numbers of my three by three array 305 00:13:52,260 --> 00:13:56,400 and the two bottom numbers on the corners, are zero. 306 00:13:56,400 --> 00:13:57,540 So if I turned them on, 307 00:13:57,540 --> 00:13:58,800 I would be in a Moore Neighborhood, 308 00:13:58,800 --> 00:14:00,650 now I'm in a Von Newman Neighborhood. 309 00:14:01,620 --> 00:14:06,300 And I'm gonna ask the code to find the connected cluster. 310 00:14:06,300 --> 00:14:07,530 So that's kind of neat to have 311 00:14:07,530 --> 00:14:10,410 a function to do it for us and label them. 312 00:14:10,410 --> 00:14:11,460 And then I'm gonna look at 313 00:14:11,460 --> 00:14:13,710 what are the sizes of those clusters 314 00:14:13,710 --> 00:14:15,630 and keep only the biggest one. 315 00:14:15,630 --> 00:14:17,580 So my second figure is gonna show us 316 00:14:17,580 --> 00:14:19,440 the biggest connected cluster, 317 00:14:19,440 --> 00:14:21,180 meaning sites that share an edge 318 00:14:21,180 --> 00:14:24,360 in this random noise of percolation. 319 00:14:24,360 --> 00:14:25,660 And we're gonna plug both. 320 00:14:26,880 --> 00:14:28,500 Once you have your Google form set up 321 00:14:28,500 --> 00:14:29,700 you can double click on it, 322 00:14:29,700 --> 00:14:32,820 get rid of the code and make it look a lot cleaner. 323 00:14:32,820 --> 00:14:34,720 Right so here I've run 324 00:14:36,300 --> 00:14:40,500 percolation with a probability of 0.35, 325 00:14:40,500 --> 00:14:41,520 which means that I know 326 00:14:41,520 --> 00:14:43,620 that there's about 35 percent of pixels 327 00:14:43,620 --> 00:14:45,280 on the left that are white 328 00:14:46,470 --> 00:14:48,660 and 65 percent are black. 329 00:14:48,660 --> 00:14:52,410 And my biggest cluster was like some connected cluster 330 00:14:52,410 --> 00:14:56,073 in the bottom right quadrant of the figure. 331 00:14:56,940 --> 00:14:57,773 And I can 332 00:14:59,460 --> 00:15:03,090 make a higher probability 0.36, that's not much higher. 333 00:15:03,090 --> 00:15:06,360 I get a slightly bigger maybe cluster in the top. 334 00:15:06,360 --> 00:15:10,830 The left will always look like pure white noise, right? 335 00:15:10,830 --> 00:15:12,750 Not much structure to find there. 336 00:15:12,750 --> 00:15:15,543 0.4, slightly bigger cluster. 337 00:15:17,070 --> 00:15:18,780 0.41 maybe, 338 00:15:18,780 --> 00:15:21,570 I've set this like step to be 0.01. 339 00:15:21,570 --> 00:15:24,690 Slightly bigger and then I can go much further. 340 00:15:24,690 --> 00:15:26,133 0.47. 341 00:15:29,023 --> 00:15:29,856 0.5. 342 00:15:31,200 --> 00:15:33,030 And I can just play a little more 343 00:15:33,030 --> 00:15:34,500 interactively with my code 344 00:15:34,500 --> 00:15:36,210 and having to like change with the keyboard 345 00:15:36,210 --> 00:15:37,740 and rerun the thing. 346 00:15:37,740 --> 00:15:38,790 0.54. 347 00:15:38,790 --> 00:15:40,920 And now they're growing and getting interesting. 348 00:15:40,920 --> 00:15:42,300 And we're seeing some of the same 349 00:15:42,300 --> 00:15:44,220 statistical features of randomness 350 00:15:44,220 --> 00:15:47,130 that we saw with random walks, right? 351 00:15:47,130 --> 00:15:50,048 Like maybe a good model for random forests. 352 00:15:50,048 --> 00:15:50,881 And, 353 00:15:50,881 --> 00:15:52,980 and by that I mean actual random forests in the world. 354 00:15:52,980 --> 00:15:56,793 Satellite imagery, looks like a smoke trail a little bit. 355 00:15:58,110 --> 00:15:58,943 And I'm growing 356 00:16:00,090 --> 00:16:01,743 and growing my clusters. 357 00:16:07,500 --> 00:16:11,703 And at some point my clusters get incredibly big. 358 00:16:13,050 --> 00:16:15,060 What's interesting is that that point 359 00:16:15,060 --> 00:16:16,920 is like actually very, very fine. 360 00:16:16,920 --> 00:16:18,100 If I had an infinite 361 00:16:19,890 --> 00:16:21,570 world to play with, 362 00:16:21,570 --> 00:16:23,650 there is one point where below it 363 00:16:24,810 --> 00:16:27,510 I expect only finite size clusters 364 00:16:27,510 --> 00:16:31,680 and above it I expect an infinite spanning clusters. 365 00:16:31,680 --> 00:16:33,270 So what a spanning cluster is, 366 00:16:33,270 --> 00:16:34,120 if I go 367 00:16:35,220 --> 00:16:36,333 a little higher, 368 00:16:38,010 --> 00:16:40,980 is this idea that if I was conducting electricity, 369 00:16:40,980 --> 00:16:43,020 for example, from top to bottom, 370 00:16:43,020 --> 00:16:44,610 in a spanning cluster, 371 00:16:44,610 --> 00:16:47,220 that cluster scales with the size of my system 372 00:16:47,220 --> 00:16:48,840 and becomes infinite. 373 00:16:48,840 --> 00:16:50,040 Or in this case would mean that 374 00:16:50,040 --> 00:16:53,640 I can conduct a signal almost for certain 375 00:16:53,640 --> 00:16:56,670 from somewhere at the bottom, somewhere on top, right? 376 00:16:56,670 --> 00:17:00,510 There exists a cluster and its size is still gonna grow. 377 00:17:00,510 --> 00:17:04,260 So if I go to 0.82, I'm still gonna get a bigger cluster 378 00:17:04,260 --> 00:17:07,770 but I still have a connected world essentially. 379 00:17:07,770 --> 00:17:09,450 And we're gonna look mathematically 380 00:17:09,450 --> 00:17:12,750 in some other models about how equations, 381 00:17:12,750 --> 00:17:15,540 very much like the tools we saw in dynamical systems, 382 00:17:15,540 --> 00:17:18,363 can help us identify those critical transition. 383 00:17:19,260 --> 00:17:20,823 It's very much like, 384 00:17:22,470 --> 00:17:24,330 if you're thinking of percolation 385 00:17:24,330 --> 00:17:26,250 as a model for disease spread, 386 00:17:26,250 --> 00:17:28,290 this isn't unlike 387 00:17:28,290 --> 00:17:30,330 the epidemic threshold that we saw 388 00:17:30,330 --> 00:17:33,120 where below a certain density, 389 00:17:33,120 --> 00:17:35,460 the disease cannot spread in the population. 390 00:17:35,460 --> 00:17:37,110 Above that epidemic threshold, 391 00:17:37,110 --> 00:17:40,590 above are not equal one can invade the system, right? 392 00:17:40,590 --> 00:17:42,810 And so we're often gonna talk about 393 00:17:42,810 --> 00:17:44,700 this critical value as the 394 00:17:44,700 --> 00:17:47,670 percolation threshold of the system. 395 00:17:47,670 --> 00:17:50,400 And from phase transition theory, 396 00:17:50,400 --> 00:17:52,740 which is the study of these critical points, 397 00:17:52,740 --> 00:17:55,050 there's a lot that we know about the behavior 398 00:17:55,050 --> 00:17:57,510 of the system around that threshold. 399 00:17:57,510 --> 00:18:00,750 So for example, I know that if I'm just around it, 400 00:18:00,750 --> 00:18:04,170 the distribution of size of these non spanning clusters 401 00:18:04,170 --> 00:18:06,750 actually follow with power law distributions, 402 00:18:06,750 --> 00:18:09,630 power laws like the mathematical forms 403 00:18:09,630 --> 00:18:12,810 that we saw in the study of fractal last week. 404 00:18:12,810 --> 00:18:14,880 And so there's a lot of connections between 405 00:18:14,880 --> 00:18:17,400 these different ideas of complexity 406 00:18:17,400 --> 00:18:19,830 when I'm at around that critical point. 407 00:18:19,830 --> 00:18:22,830 If I'm far from it, the system is boring, right? 408 00:18:22,830 --> 00:18:26,670 A fully connected system to an empty system. 409 00:18:26,670 --> 00:18:29,670 But there is a space in between, 410 00:18:29,670 --> 00:18:31,350 a space in between emptiness 411 00:18:31,350 --> 00:18:36,150 and boring order that exhibits really interesting behavior. 412 00:18:36,150 --> 00:18:37,980 And so we're gonna dig in that more 413 00:18:37,980 --> 00:18:41,250 and we're gonna use percolation as a modeling ingredient 414 00:18:41,250 --> 00:18:43,620 to think about a lot of different system. 415 00:18:43,620 --> 00:18:45,180 So I'll put all of this online. 416 00:18:45,180 --> 00:18:48,090 I'll invite you to play with them, do your own models, 417 00:18:48,090 --> 00:18:51,033 and then we can discuss that more in discussion group. 418 00:18:53,850 --> 00:18:58,300 And I'll also share some videos of my own models of 419 00:18:59,220 --> 00:19:02,250 stochastic CA and I'll start connecting ideas 420 00:19:02,250 --> 00:19:04,380 from module one and module two. 421 00:19:04,380 --> 00:19:06,090 So in one of the videos I'll share 422 00:19:06,090 --> 00:19:07,320 I'll try and tell you the story 423 00:19:07,320 --> 00:19:09,090 of how the forest got its shape. 424 00:19:09,090 --> 00:19:11,310 Which uses ideas from percolation 425 00:19:11,310 --> 00:19:13,440 and dynamical system into one story. 426 00:19:13,440 --> 00:19:15,420 So I'll see you for that in the next one. 427 00:19:15,420 --> 00:19:16,253 Bye.