1 00:00:04,400 --> 00:00:07,800 Speaker 1: Welcome to tech Stuff, a production from I Heart Radio. 2 00:00:12,119 --> 00:00:14,920 Speaker 1: Hey there, and welcome to tech Stuff. I'm your host, 3 00:00:15,080 --> 00:00:18,000 Speaker 1: Jonathan Strickland. I'm an executive producer with I Heart Radio 4 00:00:18,079 --> 00:00:21,600 Speaker 1: and a love of all things tech, and I frequently 5 00:00:21,840 --> 00:00:25,600 Speaker 1: speak about algorithms on this show. I talked about them 6 00:00:25,640 --> 00:00:30,120 Speaker 1: all the time, talk about Facebook's algorithm or YouTube's algorithm. 7 00:00:30,240 --> 00:00:34,440 Speaker 1: We talk about search algorithms and recommendation algorithms and tons 8 00:00:34,680 --> 00:00:37,800 Speaker 1: of others. But I haven't really spent a ton of 9 00:00:37,840 --> 00:00:42,760 Speaker 1: time talking about what algorithms actually are. Like it kind 10 00:00:42,760 --> 00:00:47,519 Speaker 1: of becomes shorthand for do not look behind the curtain, right, 11 00:00:47,680 --> 00:00:49,959 Speaker 1: It doesn't really help you if you don't know more 12 00:00:50,080 --> 00:00:53,160 Speaker 1: about it. I might go as far as to say 13 00:00:53,200 --> 00:00:55,680 Speaker 1: it's a set of rules or instructions to carry out 14 00:00:55,680 --> 00:00:59,120 Speaker 1: a task, but that's pretty reductive and it doesn't really 15 00:00:59,160 --> 00:01:02,280 Speaker 1: help you understand and what algorithms actually do. So today 16 00:01:02,800 --> 00:01:05,640 Speaker 1: I thought we'd talk a little bit about algorithms and 17 00:01:05,720 --> 00:01:08,360 Speaker 1: what they do in general, and then maybe chat about 18 00:01:08,360 --> 00:01:11,600 Speaker 1: a few famous examples and some fun, little quirky stuff. 19 00:01:11,680 --> 00:01:15,480 Speaker 1: So before I dive into this, we do need to 20 00:01:15,600 --> 00:01:20,759 Speaker 1: establish a few things, and arguably the most important of 21 00:01:20,800 --> 00:01:24,360 Speaker 1: those things is that I am not a mathematician, I 22 00:01:24,400 --> 00:01:28,120 Speaker 1: am not a computer scientist. I'm a guy who loves tech, 23 00:01:28,520 --> 00:01:32,279 Speaker 1: and I'm decent at research, and I do my best 24 00:01:32,360 --> 00:01:36,480 Speaker 1: to communicate topics in an informative and you know, on 25 00:01:36,520 --> 00:01:39,839 Speaker 1: a good day and entertaining way. So with that in mind, 26 00:01:40,280 --> 00:01:43,000 Speaker 1: I fully admit that this is a subject that is 27 00:01:43,040 --> 00:01:48,160 Speaker 1: outside of my narrow expertise, and so my descriptions and 28 00:01:48,240 --> 00:01:52,800 Speaker 1: explanations will be from a very high level. And you 29 00:01:52,880 --> 00:01:55,560 Speaker 1: might even be able to get something like this just 30 00:01:55,640 --> 00:01:59,480 Speaker 1: by glancing at a pamphlet that's about a computer science 31 00:01:59,520 --> 00:02:04,280 Speaker 1: introduct the recourse. So for all you folks out there 32 00:02:04,280 --> 00:02:06,480 Speaker 1: who are deep in the computer sciences, this is going 33 00:02:06,520 --> 00:02:10,760 Speaker 1: to be like a children's story book for you, possibly 34 00:02:10,880 --> 00:02:15,520 Speaker 1: one where you don't like the illustrations very much. Another 35 00:02:15,600 --> 00:02:19,600 Speaker 1: thing that I need to establish is that algorithm itself 36 00:02:19,680 --> 00:02:23,560 Speaker 1: is a very broad term, you know, in that sense 37 00:02:23,680 --> 00:02:28,079 Speaker 1: it's kind of like the word program or app or software, 38 00:02:28,639 --> 00:02:32,040 Speaker 1: and that these words are categories that can have a 39 00:02:32,080 --> 00:02:36,320 Speaker 1: wide variety of specific instances. For example, let's just take 40 00:02:36,320 --> 00:02:39,040 Speaker 1: a look at software. If I'm talking about software, I 41 00:02:39,040 --> 00:02:43,240 Speaker 1: could be talking about a very simple program that serves 42 00:02:43,360 --> 00:02:47,520 Speaker 1: as a basic calculator that can add and subtract and 43 00:02:47,520 --> 00:02:51,160 Speaker 1: divide and multiply. That could be a piece of software, 44 00:02:51,240 --> 00:02:53,919 Speaker 1: be a very simple one, or I might talk about 45 00:02:53,960 --> 00:02:57,760 Speaker 1: something a little more complicated, like a word processing program. 46 00:02:57,919 --> 00:03:01,240 Speaker 1: Or I could talk about an advanced three D shooter 47 00:03:01,480 --> 00:03:07,720 Speaker 1: video game, or an incredibly complicated computer simulation program, or 48 00:03:07,760 --> 00:03:10,240 Speaker 1: anything in between. All of those could fall into the 49 00:03:10,280 --> 00:03:14,760 Speaker 1: realm of software well. Algorithms similarly come in a wide 50 00:03:14,840 --> 00:03:19,000 Speaker 1: variety of functions and complexity. There are some that are 51 00:03:19,000 --> 00:03:23,119 Speaker 1: elegant in their simplicity, and there are some that when 52 00:03:23,120 --> 00:03:26,000 Speaker 1: I look at them written out in in what is 53 00:03:26,320 --> 00:03:33,600 Speaker 1: clearly well defined terminology, uh, I'm just left wondering what 54 00:03:33,639 --> 00:03:35,600 Speaker 1: the heck it is I just saw. They might as 55 00:03:35,600 --> 00:03:38,680 Speaker 1: well be hieroglyphics to me. In other words, But let's 56 00:03:38,680 --> 00:03:43,400 Speaker 1: start off by talking about the word algorithm itself. Now, 57 00:03:44,640 --> 00:03:48,720 Speaker 1: unlike a lot of words that we use specifically in English, 58 00:03:49,240 --> 00:03:53,920 Speaker 1: algorithm does not have its roots in Latin vocabulary. There 59 00:03:53,960 --> 00:03:57,400 Speaker 1: are words in Latin that are like al gore and 60 00:03:57,480 --> 00:04:01,040 Speaker 1: things like that, but that's not where algorithm comes from. Instead, 61 00:04:01,720 --> 00:04:07,600 Speaker 1: it's a latinized version of an Arabic name. Algorithm comes 62 00:04:07,600 --> 00:04:10,920 Speaker 1: from algorithmic, which is the name that Latin scholars gave 63 00:04:10,960 --> 00:04:15,160 Speaker 1: to a brilliant man named al qua Ritzmy and my 64 00:04:15,320 --> 00:04:19,000 Speaker 1: apologies for the butchering of the pronunciation of that name. 65 00:04:19,200 --> 00:04:24,840 Speaker 1: No disrespect is intended. It's merely American ignorance. Anyway. This 66 00:04:24,960 --> 00:04:31,719 Speaker 1: particular mathematician philosophers scholar served as a very important astronomer 67 00:04:31,760 --> 00:04:36,200 Speaker 1: and librarian in Baghdad in the ninth century. His work 68 00:04:36,240 --> 00:04:40,479 Speaker 1: in mathematics was truly foundational, so much so that we 69 00:04:40,600 --> 00:04:44,680 Speaker 1: get the word algebra from a work that he published. 70 00:04:45,320 --> 00:04:49,440 Speaker 1: He treated algebra as a distinct branch of mathematics, when 71 00:04:49,520 --> 00:04:51,799 Speaker 1: before it was just kind of lumped in with other stuff. 72 00:04:52,160 --> 00:04:54,360 Speaker 1: And he did a lot of work in showing how 73 00:04:54,440 --> 00:04:58,400 Speaker 1: to work various types of equations and how to balance equations. 74 00:04:58,600 --> 00:05:02,039 Speaker 1: And on a personal note, this was something that I 75 00:05:02,160 --> 00:05:04,800 Speaker 1: used to love to do in my mathematics courses. I 76 00:05:04,839 --> 00:05:08,279 Speaker 1: could really see the beauty in determining if two sides 77 00:05:08,320 --> 00:05:11,960 Speaker 1: of an equation truly were equal. It was like an 78 00:05:12,000 --> 00:05:15,240 Speaker 1: elegant puzzle and I really love that. But again, just 79 00:05:15,279 --> 00:05:18,000 Speaker 1: to be clear, my love of algebra and trigonometry is 80 00:05:18,040 --> 00:05:21,240 Speaker 1: pretty much where math and I parted ways, because when 81 00:05:21,279 --> 00:05:25,080 Speaker 1: calculus came along, I was I was pretty much done, 82 00:05:25,160 --> 00:05:27,640 Speaker 1: so at that point it was it was beyond my 83 00:05:27,880 --> 00:05:33,080 Speaker 1: ken as they say. Anyway, back to our Arabic scholar, 84 00:05:33,520 --> 00:05:38,000 Speaker 1: he highlighted the importance and effectiveness of using a methodical 85 00:05:38,160 --> 00:05:42,760 Speaker 1: approach towards the solution of problems, and that kind of 86 00:05:42,800 --> 00:05:47,440 Speaker 1: gets at the heart of what algorithms actually are. The 87 00:05:47,480 --> 00:05:51,240 Speaker 1: basic definition, which I kind of alluded to earlier is 88 00:05:51,480 --> 00:05:55,400 Speaker 1: quote a process or set of rules to be followed 89 00:05:55,480 --> 00:06:00,640 Speaker 1: in calculations or other problems solving operations, especially by a 90 00:06:00,640 --> 00:06:05,080 Speaker 1: computer end quote that's from Oxford Languages. But you know 91 00:06:05,480 --> 00:06:07,560 Speaker 1: this can apply to all sorts of stuff. For example, 92 00:06:07,760 --> 00:06:11,719 Speaker 1: if you've ever seen anyone who can solve Rubik's cubes, 93 00:06:12,160 --> 00:06:15,040 Speaker 1: those those puzzles that are in cube form where you've 94 00:06:15,040 --> 00:06:17,760 Speaker 1: got all the little, uh different colors of squares and 95 00:06:17,800 --> 00:06:20,440 Speaker 1: your job is to make each side of the cube 96 00:06:20,480 --> 00:06:24,080 Speaker 1: the same color. Well, there are people who can solve 97 00:06:24,160 --> 00:06:27,800 Speaker 1: Rubik's cubes in in in a fraction of like, like 98 00:06:28,000 --> 00:06:30,359 Speaker 1: less than a minute. It's it's amazing to watch them go. 99 00:06:30,480 --> 00:06:33,400 Speaker 1: It's so fast and it's hard to keep up with 100 00:06:33,400 --> 00:06:39,080 Speaker 1: what they're doing. They are essentially following algorithms these processes 101 00:06:39,200 --> 00:06:45,799 Speaker 1: that will get to a dependable and replicable outcome based 102 00:06:45,839 --> 00:06:49,120 Speaker 1: on what you're doing. Um So, an algorithm is really 103 00:06:49,160 --> 00:06:52,279 Speaker 1: just a way for us to problem solve. Let's say 104 00:06:52,279 --> 00:06:54,920 Speaker 1: we have a particular outcome that we want to achieve. 105 00:06:55,240 --> 00:06:58,320 Speaker 1: The algorithm is the recipe that we followed to go 106 00:06:58,440 --> 00:07:01,320 Speaker 1: from whatever our starting can to. S is our starting 107 00:07:01,360 --> 00:07:04,680 Speaker 1: state in order to get to the outcome we want 108 00:07:04,680 --> 00:07:08,640 Speaker 1: to our target state, it needs to be well defined. 109 00:07:08,920 --> 00:07:11,280 Speaker 1: Algorithms have to be well defined because computers are not 110 00:07:11,320 --> 00:07:15,960 Speaker 1: really capable of implementing vague instructions. It needs to have 111 00:07:16,800 --> 00:07:19,600 Speaker 1: a pretty solid approach so that the computer, when following 112 00:07:19,640 --> 00:07:23,280 Speaker 1: the algorithm quote unquote, knows exactly what to do based 113 00:07:23,320 --> 00:07:26,880 Speaker 1: upon the current state of the problem. It also needs 114 00:07:26,880 --> 00:07:32,320 Speaker 1: to be finite. Computers are not capable of handling infinite possibilities, 115 00:07:32,800 --> 00:07:36,080 Speaker 1: so the algorithm has to work within certain parameters, and 116 00:07:36,160 --> 00:07:39,240 Speaker 1: those parameters depend upon the nature of the problem you're 117 00:07:39,280 --> 00:07:42,080 Speaker 1: trying to solve and the equipment that you have to 118 00:07:42,160 --> 00:07:46,200 Speaker 1: solve it with. So let's take a problem that computers 119 00:07:46,320 --> 00:07:51,360 Speaker 1: typically struggle to achieve, and that is random number generation 120 00:07:51,680 --> 00:07:55,200 Speaker 1: or r n G. Now, you would think that creating 121 00:07:55,240 --> 00:07:58,680 Speaker 1: a random number would be easy. I mean, we can 122 00:07:58,720 --> 00:08:01,880 Speaker 1: do it just by throwing some dice for example, Right, 123 00:08:01,920 --> 00:08:04,280 Speaker 1: you can throw a die and and whatever the number 124 00:08:04,560 --> 00:08:08,360 Speaker 1: comes up, that's your random number. But computers have to 125 00:08:08,400 --> 00:08:13,600 Speaker 1: follow specific instructions and execute operations that by definition need 126 00:08:13,640 --> 00:08:17,400 Speaker 1: to have a predictable and replicable outcomes. So computers find 127 00:08:17,480 --> 00:08:22,480 Speaker 1: random number generation really tricky. Typically, the best we can 128 00:08:22,520 --> 00:08:25,560 Speaker 1: hope for when it comes down to this sort of 129 00:08:25,600 --> 00:08:29,640 Speaker 1: thing is pseudo random numbers. So these are numbers that, 130 00:08:29,760 --> 00:08:33,480 Speaker 1: to an extent, appear to be random, right Like, on 131 00:08:33,720 --> 00:08:38,920 Speaker 1: casual observation, it looks like the computer is generating random numbers. However, 132 00:08:38,960 --> 00:08:42,720 Speaker 1: if you were to really seriously dig down into the process, 133 00:08:43,160 --> 00:08:46,480 Speaker 1: you might discover that they are not really random at all. 134 00:08:47,120 --> 00:08:49,760 Speaker 1: But we just need them to be random enough, right. 135 00:08:49,840 --> 00:08:52,720 Speaker 1: We need it to be close enough to seeming to 136 00:08:52,760 --> 00:08:55,400 Speaker 1: be random for it to fulfill the function we need. 137 00:08:55,880 --> 00:08:59,000 Speaker 1: If it's not truly random for a lot of applications, 138 00:08:59,559 --> 00:09:04,320 Speaker 1: that ends being you know, negligible. On a related note, 139 00:09:04,720 --> 00:09:07,960 Speaker 1: there are some types of mathematical problems that have many 140 00:09:07,960 --> 00:09:12,280 Speaker 1: degrees of freedom lots of variables. For example, so a 141 00:09:12,360 --> 00:09:14,360 Speaker 1: problem that does have a lot of variables could have 142 00:09:14,360 --> 00:09:16,959 Speaker 1: a lot of potential solutions, and so it could be 143 00:09:17,000 --> 00:09:20,480 Speaker 1: a challenge for computers to solve. We need algorithms to 144 00:09:20,480 --> 00:09:24,040 Speaker 1: tackle these sorts of problems, to go at them in 145 00:09:24,080 --> 00:09:29,240 Speaker 1: ways that go beyond deterministic computation, which I guess I 146 00:09:29,280 --> 00:09:34,160 Speaker 1: should define that. So, deterministic computation refers to a process 147 00:09:34,200 --> 00:09:39,000 Speaker 1: in which each successive state of an operation depends completely 148 00:09:39,080 --> 00:09:43,640 Speaker 1: on the previous state. So what comes next always depends 149 00:09:43,720 --> 00:09:47,120 Speaker 1: upon what came just before. And I'll give you an example. 150 00:09:47,440 --> 00:09:49,480 Speaker 1: Let's say I give you a math problem. I say 151 00:09:49,960 --> 00:09:52,000 Speaker 1: you need to add these two numbers together. And let's 152 00:09:52,000 --> 00:09:55,839 Speaker 1: say it's like, uh, five and six, and then from 153 00:09:55,960 --> 00:09:59,040 Speaker 1: the sum of those numbers you have to subtract four. Well, 154 00:09:59,280 --> 00:10:01,960 Speaker 1: you at first add those two numbers together, so five 155 00:10:02,000 --> 00:10:05,160 Speaker 1: plus six you got eleven, and then you would subtract 156 00:10:05,679 --> 00:10:10,240 Speaker 1: four from that number, and so eleven minus four equals seven. 157 00:10:10,840 --> 00:10:14,160 Speaker 1: And this process is deterministic, because I gave you those 158 00:10:14,160 --> 00:10:19,600 Speaker 1: specific instructions that computers do really well with deterministic processes. 159 00:10:19,679 --> 00:10:23,440 Speaker 1: These are pretty easy to follow. These sorts of processes 160 00:10:23,480 --> 00:10:27,160 Speaker 1: are by their nature replicable. So in other words, if 161 00:10:27,200 --> 00:10:30,240 Speaker 1: I ask you to do that same operation. If I 162 00:10:30,280 --> 00:10:33,520 Speaker 1: tell you add five and six together and then subtract four, 163 00:10:34,360 --> 00:10:36,400 Speaker 1: it doesn't matter how many times you are you do 164 00:10:36,520 --> 00:10:38,959 Speaker 1: that that process, right, You're always going to come out 165 00:10:39,559 --> 00:10:41,840 Speaker 1: with the same answer. It's always going to come back 166 00:10:42,200 --> 00:10:45,680 Speaker 1: no matter what you do, You're gonna always have seven 167 00:10:45,760 --> 00:10:49,480 Speaker 1: as your answer, just based on that same input. So 168 00:10:49,840 --> 00:10:53,840 Speaker 1: there are a family of algorithms that collectively get the 169 00:10:53,920 --> 00:10:58,680 Speaker 1: name Monte Carlo algorithms, and they're named after Monte Carlo, 170 00:10:58,920 --> 00:11:01,400 Speaker 1: the area of Monaco that is famous for being the 171 00:11:01,440 --> 00:11:05,480 Speaker 1: location of lots of high end casinos have been there. 172 00:11:05,960 --> 00:11:09,680 Speaker 1: It's not really my jam, but it is pretty darn flashy. 173 00:11:10,240 --> 00:11:14,559 Speaker 1: So the reason these algorithms get the name Monte Carlo 174 00:11:14,640 --> 00:11:19,400 Speaker 1: algorithms is that, like gambling, they deal with an element 175 00:11:19,480 --> 00:11:24,680 Speaker 1: of randomization. So gambling is called gambling because you're taking 176 00:11:24,679 --> 00:11:28,760 Speaker 1: a risk. You're gambling, you're betting that you're gonna beat 177 00:11:28,800 --> 00:11:31,400 Speaker 1: the odds in whichever game it is that you're playing, 178 00:11:31,520 --> 00:11:34,439 Speaker 1: and that you're going to achieve an outcome that's favorable 179 00:11:34,480 --> 00:11:38,120 Speaker 1: to you, which you experience as a payout. So whether 180 00:11:38,160 --> 00:11:41,720 Speaker 1: it's throwing dice or playing a card game or placing 181 00:11:41,720 --> 00:11:45,200 Speaker 1: bets at a roulette wheel or playing a slot machine. 182 00:11:45,280 --> 00:11:47,880 Speaker 1: You are engaged in an activity in which there is 183 00:11:48,080 --> 00:11:51,800 Speaker 1: some element of chance, at least in theory if the 184 00:11:51,800 --> 00:11:55,000 Speaker 1: game is honest, and what you're hoping for is that 185 00:11:55,400 --> 00:12:00,280 Speaker 1: chance lands in your favor. Similarly, Monty car are Low 186 00:12:00,360 --> 00:12:04,440 Speaker 1: algorithms often focus on chance and risk assessments such as 187 00:12:04,880 --> 00:12:08,200 Speaker 1: what are the odds that if I do this one thing, 188 00:12:08,840 --> 00:12:12,480 Speaker 1: I'm gonna totally regret doing it later? But you know, 189 00:12:12,640 --> 00:12:15,320 Speaker 1: more of the as a computational problem and not a 190 00:12:15,400 --> 00:12:20,959 Speaker 1: lifestyle choice. Well, back in nineteen scientists at the Los 191 00:12:21,040 --> 00:12:25,920 Speaker 1: Alamos Scientific Laboratory, including John von Neumann, uh stand All 192 00:12:26,200 --> 00:12:30,240 Speaker 1: Lam and Nick Metropolis, proposed what would become known as 193 00:12:30,240 --> 00:12:34,960 Speaker 1: the Metropolis algorithm, one of the Monte Carlo algorithms, and 194 00:12:35,000 --> 00:12:39,199 Speaker 1: the purpose of this algorithm was to approximate solutions two 195 00:12:39,440 --> 00:12:45,559 Speaker 1: very complicated mathematical problems where going through a deterministic approach 196 00:12:45,880 --> 00:12:49,640 Speaker 1: to find the definitive answer just wasn't feasible. So, in 197 00:12:49,679 --> 00:12:53,160 Speaker 1: other words, for certain complicated math problems, figuring out the 198 00:12:53,200 --> 00:12:56,839 Speaker 1: quote unquote real answer would really just take too long, 199 00:12:57,240 --> 00:12:59,480 Speaker 1: perhaps to the point where you would never get there 200 00:12:59,480 --> 00:13:02,240 Speaker 1: within your lifetime. So you need a way to kind 201 00:13:02,280 --> 00:13:05,959 Speaker 1: of get a ballpark solution that hopefully is closer to 202 00:13:06,000 --> 00:13:09,720 Speaker 1: being correct than incorrect. Doesn't sound like the sort of 203 00:13:09,720 --> 00:13:12,080 Speaker 1: thing that computers would be particularly good at doing right 204 00:13:12,120 --> 00:13:15,960 Speaker 1: off the bat. Right. In fact, the algorithm allows computers 205 00:13:16,000 --> 00:13:20,320 Speaker 1: to mimic a randomized process, so it's not truly random, 206 00:13:20,520 --> 00:13:24,120 Speaker 1: but it's random ish if you like, And it uses 207 00:13:24,160 --> 00:13:27,320 Speaker 1: this to approximate a solution to whatever the problem is 208 00:13:27,360 --> 00:13:30,440 Speaker 1: that you're trying to solve that falls into this category. 209 00:13:30,600 --> 00:13:34,320 Speaker 1: I once saw a simulation of a randomized process using 210 00:13:34,320 --> 00:13:38,640 Speaker 1: the Monte Carlo method that I thought was pretty nifty, 211 00:13:38,760 --> 00:13:41,560 Speaker 1: and it was determining what is the value of pie. 212 00:13:41,679 --> 00:13:44,840 Speaker 1: Let's say that you don't know the value of pie 213 00:13:45,120 --> 00:13:47,640 Speaker 1: and you're just trying to figure it out. So and 214 00:13:47,679 --> 00:13:49,400 Speaker 1: by the way, I mean pie is in p I 215 00:13:49,480 --> 00:13:53,840 Speaker 1: not as in the delicious pie dessert treat. So here's 216 00:13:53,880 --> 00:13:56,720 Speaker 1: the scenario. Imagine that you've got a table and the 217 00:13:56,760 --> 00:13:59,520 Speaker 1: tables like I don't know, three ft to a side, 218 00:14:00,040 --> 00:14:03,920 Speaker 1: and positioned over this table is a robotic arm, and 219 00:14:04,000 --> 00:14:07,720 Speaker 1: this robotic arm can pick up and drop large ball 220 00:14:07,800 --> 00:14:11,760 Speaker 1: bearings onto the table, and the arm can just move 221 00:14:11,880 --> 00:14:13,920 Speaker 1: over the entire region of the table, so it's got 222 00:14:13,920 --> 00:14:17,360 Speaker 1: a three ft by three ft range of motion. And 223 00:14:17,640 --> 00:14:21,880 Speaker 1: in on this table you set down two containers. You've 224 00:14:21,920 --> 00:14:26,360 Speaker 1: got one that's that's a circular container, and one that's square. 225 00:14:26,960 --> 00:14:31,160 Speaker 1: And the square container measures six inches to a side. Uh, 226 00:14:31,280 --> 00:14:35,440 Speaker 1: the radius of the circular circular container is also six inches, 227 00:14:35,480 --> 00:14:37,800 Speaker 1: so that means it's got a twelve inch diameter. Right. 228 00:14:38,080 --> 00:14:42,160 Speaker 1: So those are your containers, and you've got your situation 229 00:14:42,200 --> 00:14:45,680 Speaker 1: with your your robot arm above this three ft square table. 230 00:14:46,440 --> 00:14:48,840 Speaker 1: So the robotic arms job is to pick up ball 231 00:14:48,880 --> 00:14:54,320 Speaker 1: bearings and then from a random que will drop that 232 00:14:54,360 --> 00:14:58,120 Speaker 1: ball bearing somewhere above the table. So some of those 233 00:14:58,160 --> 00:15:00,920 Speaker 1: balls are going to fall into the square container, some 234 00:15:01,040 --> 00:15:03,720 Speaker 1: of them are going to fall into the round container. 235 00:15:03,800 --> 00:15:05,440 Speaker 1: Some of them are not going to fall in either. 236 00:15:06,200 --> 00:15:09,720 Speaker 1: And if the process is truly random, meaning there's an 237 00:15:09,800 --> 00:15:12,600 Speaker 1: equal chance that it will drop a ball bearing over 238 00:15:12,680 --> 00:15:16,800 Speaker 1: any given point of that table, over time, we would 239 00:15:16,800 --> 00:15:19,600 Speaker 1: expect to see more ball bearings fall into the round 240 00:15:19,680 --> 00:15:24,040 Speaker 1: container because it has a greater area and there's more 241 00:15:24,080 --> 00:15:27,360 Speaker 1: space for a ball bearing to fall into one of these. 242 00:15:27,920 --> 00:15:31,680 Speaker 1: At the end of repeating this process many many times, 243 00:15:32,000 --> 00:15:35,080 Speaker 1: we should be able to take these two containers and 244 00:15:35,120 --> 00:15:38,360 Speaker 1: then count the number of ball bearings in each of them. 245 00:15:38,440 --> 00:15:41,360 Speaker 1: And if we divide the number of ball bearings in 246 00:15:41,400 --> 00:15:44,680 Speaker 1: the circular container by the number of ball bearings that 247 00:15:44,720 --> 00:15:48,200 Speaker 1: fell into the square container, we're gonna get results that 248 00:15:48,240 --> 00:15:52,960 Speaker 1: should be really close to pie. And you might think, wait, 249 00:15:54,480 --> 00:15:57,960 Speaker 1: why why would the number of ball bearings in one 250 00:15:58,000 --> 00:16:01,680 Speaker 1: container versus another, and then divide fighting those why would 251 00:16:01,720 --> 00:16:04,160 Speaker 1: you get pie? Well, if you have a process that 252 00:16:04,400 --> 00:16:08,440 Speaker 1: is uniformly random across an area, like our hypothetical three 253 00:16:08,440 --> 00:16:12,520 Speaker 1: ft square table, the probability that a dropped ball bearing 254 00:16:12,520 --> 00:16:16,240 Speaker 1: will land in one of those two specific containers is 255 00:16:16,240 --> 00:16:21,120 Speaker 1: proportional to that specific containers area or cross section. So 256 00:16:21,520 --> 00:16:23,080 Speaker 1: then we just ask, all, right, well, how do we 257 00:16:23,160 --> 00:16:25,960 Speaker 1: define area? Well, with the square, it's really simple, right. 258 00:16:26,040 --> 00:16:28,800 Speaker 1: We take one side of a square in this case, 259 00:16:28,800 --> 00:16:32,080 Speaker 1: it's six inches, and we multiply it by itself six 260 00:16:32,120 --> 00:16:34,960 Speaker 1: times six. Because all sides of a square are equal, 261 00:16:35,040 --> 00:16:36,960 Speaker 1: we know that the length and the width are each 262 00:16:37,000 --> 00:16:39,760 Speaker 1: going to be six inches. We multiply those together. We 263 00:16:39,800 --> 00:16:42,840 Speaker 1: get thirty six square inches. That is the area or 264 00:16:42,960 --> 00:16:47,360 Speaker 1: cross section of our square container. But for our circular container, 265 00:16:48,000 --> 00:16:50,760 Speaker 1: we take the radius, which again in this case the 266 00:16:50,840 --> 00:16:53,960 Speaker 1: radius is six inches, and we square it and then 267 00:16:54,040 --> 00:16:59,000 Speaker 1: we multiply that number by pie. So area for the 268 00:16:59,120 --> 00:17:03,720 Speaker 1: circular contain or is six times six squared times pie. 269 00:17:03,840 --> 00:17:06,640 Speaker 1: And if we divide the cross section of the circular 270 00:17:06,680 --> 00:17:10,679 Speaker 1: container by the cross section of the square container, the 271 00:17:10,800 --> 00:17:15,600 Speaker 1: two six squared, you know, the two elements the squared 272 00:17:15,600 --> 00:17:18,400 Speaker 1: elements cancel each other out, and so all we're left 273 00:17:18,400 --> 00:17:22,120 Speaker 1: with is pie. So the end result is that when 274 00:17:22,160 --> 00:17:25,520 Speaker 1: we count up these ball bearings that have landed randomly 275 00:17:25,560 --> 00:17:29,399 Speaker 1: in these containers, that that difference, the division that we 276 00:17:29,520 --> 00:17:33,480 Speaker 1: get that should be a close approximation of pie. Now 277 00:17:33,520 --> 00:17:36,160 Speaker 1: it's not going to be precise. Chances are the number 278 00:17:36,160 --> 00:17:38,680 Speaker 1: of ball bearings in the two containers will just get 279 00:17:38,720 --> 00:17:42,560 Speaker 1: you close to pie. But it illustrates how a randomized 280 00:17:42,600 --> 00:17:46,480 Speaker 1: process can help you get to a particular solution that 281 00:17:46,600 --> 00:17:50,479 Speaker 1: might otherwise be difficult to ascertain. There are videos on 282 00:17:50,480 --> 00:17:53,359 Speaker 1: YouTube that show this particular simulation. It's kind of a 283 00:17:53,400 --> 00:17:56,400 Speaker 1: famous one, so you can actually watch and get kind 284 00:17:56,400 --> 00:17:58,520 Speaker 1: of an understanding of what I said to you makes 285 00:17:58,600 --> 00:18:02,159 Speaker 1: no sense whatsoever. There are other options for you to 286 00:18:02,240 --> 00:18:06,040 Speaker 1: look into that might help, and that is a great example. 287 00:18:06,600 --> 00:18:09,479 Speaker 1: But what are the actual algorithms that fall into the 288 00:18:09,560 --> 00:18:13,720 Speaker 1: Monte Carlo methods spectrum? What are they used to do well? 289 00:18:13,800 --> 00:18:17,119 Speaker 1: They can be used to simulate things like fluid dynamics 290 00:18:17,280 --> 00:18:21,919 Speaker 1: or cellular structures or the interaction of disordered materials. So 291 00:18:21,960 --> 00:18:25,159 Speaker 1: in other words, these are all processes. They have a 292 00:18:25,240 --> 00:18:28,600 Speaker 1: lot of potential variables at play, and you can think 293 00:18:28,640 --> 00:18:33,200 Speaker 1: of variables as representing uncertainty, something that computers typically don't 294 00:18:33,359 --> 00:18:37,679 Speaker 1: do well with. You know, from a general stance, computers 295 00:18:37,760 --> 00:18:43,640 Speaker 1: excel at specific instances rather than potential instances. So algorithms 296 00:18:43,680 --> 00:18:48,400 Speaker 1: like the Metropolis algorithm would lead computer scientists to develop 297 00:18:48,560 --> 00:18:52,719 Speaker 1: methodologies to kind of work around the limitations of computers 298 00:18:52,720 --> 00:18:58,359 Speaker 1: and leverage computational power and tackling very difficult problems in 299 00:18:58,400 --> 00:19:02,199 Speaker 1: that way. In the Monte Carlo family of algorithms, we 300 00:19:02,280 --> 00:19:05,600 Speaker 1: typically assume that the results we get are going to 301 00:19:06,560 --> 00:19:09,119 Speaker 1: have a potential for being wrong, like there'll be a 302 00:19:09,160 --> 00:19:12,080 Speaker 1: small percentage of error that we have to take into account, 303 00:19:12,640 --> 00:19:14,600 Speaker 1: and so keeping that in mind, we need to frame 304 00:19:14,640 --> 00:19:18,480 Speaker 1: results as being again approximations of an answer rather than 305 00:19:18,560 --> 00:19:21,800 Speaker 1: the definitive answer to whatever problem it is we're trying 306 00:19:21,840 --> 00:19:24,120 Speaker 1: to solve. For me, this was one of those things 307 00:19:24,119 --> 00:19:26,919 Speaker 1: that was very difficult to grasp for a long time 308 00:19:27,080 --> 00:19:30,480 Speaker 1: because I was equating it to math class, where you're 309 00:19:30,480 --> 00:19:33,359 Speaker 1: supposed to get the answer. Now, when we come back, 310 00:19:33,560 --> 00:19:36,360 Speaker 1: we'll talk about a few more famous algorithms and what 311 00:19:36,400 --> 00:19:46,720 Speaker 1: they do. But first let's take a quick break. Now. 312 00:19:46,760 --> 00:19:49,080 Speaker 1: In our previous section, I talked about a family of 313 00:19:49,119 --> 00:19:52,840 Speaker 1: algorithms that trace their history back to nineteen and so 314 00:19:52,960 --> 00:19:55,200 Speaker 1: does the next one I want to talk about, which 315 00:19:55,240 --> 00:19:59,879 Speaker 1: was created by George Dantzig who worked for the Rand Corporation, 316 00:20:00,040 --> 00:20:03,520 Speaker 1: and Danzig created a process that would lead to what 317 00:20:03,560 --> 00:20:08,160 Speaker 1: we call linear programming. So at its most basic level, 318 00:20:08,400 --> 00:20:12,919 Speaker 1: linear programming is about taking some function and maximizing or 319 00:20:13,040 --> 00:20:17,119 Speaker 1: minimizing that function with regard to various constraints. But that 320 00:20:17,200 --> 00:20:19,800 Speaker 1: is super vague, right, I mean, it's not terribly helpful. 321 00:20:20,080 --> 00:20:22,520 Speaker 1: It feels like I'm talking in a circle. But this 322 00:20:22,600 --> 00:20:26,320 Speaker 1: is one that's really important for say, business developers. So 323 00:20:26,400 --> 00:20:29,600 Speaker 1: let's talk about a slightly more specific use case. Let's 324 00:20:29,600 --> 00:20:32,680 Speaker 1: say that you are launching a business and you're trying 325 00:20:32,720 --> 00:20:35,800 Speaker 1: to make some you know, big decisions as you're going 326 00:20:35,840 --> 00:20:38,840 Speaker 1: to do this, and you're going to manufacture and sell 327 00:20:39,040 --> 00:20:42,439 Speaker 1: a product of some sort, some physical thing. Now, your 328 00:20:42,480 --> 00:20:45,800 Speaker 1: whole goal as a business is to make money from 329 00:20:46,000 --> 00:20:48,359 Speaker 1: the work you do, and to do that, you need 330 00:20:48,400 --> 00:20:50,720 Speaker 1: to figure out what your costs are going to be 331 00:20:51,359 --> 00:20:55,400 Speaker 1: and how you cannot just offset these costs but make 332 00:20:55,520 --> 00:20:59,440 Speaker 1: enough money to actually profit from it, so cover all 333 00:20:59,480 --> 00:21:03,360 Speaker 1: your costs plus some extra. So in this case, what 334 00:21:03,400 --> 00:21:05,560 Speaker 1: you're trying to do is figuring out how you can 335 00:21:05,600 --> 00:21:11,720 Speaker 1: minimize costs and maximize profits. Right. The constraints come into 336 00:21:11,720 --> 00:21:15,080 Speaker 1: play as you start to look at specifics, like maybe 337 00:21:15,119 --> 00:21:18,200 Speaker 1: you're gonna partner with a fabrication company, and maybe you've 338 00:21:18,200 --> 00:21:20,679 Speaker 1: actually got a few choices. You've got different companies that 339 00:21:20,720 --> 00:21:23,679 Speaker 1: you could go with. Well, these choices could represent constraints 340 00:21:23,680 --> 00:21:27,480 Speaker 1: in your approach. Perhaps one is more expensive than the others, 341 00:21:27,480 --> 00:21:31,200 Speaker 1: but it can produce a greater volume of product, so 342 00:21:31,440 --> 00:21:34,119 Speaker 1: you'd be able to get more product out to market 343 00:21:34,280 --> 00:21:38,480 Speaker 1: in less time. Or maybe you've got one that's more expensive, 344 00:21:38,600 --> 00:21:42,800 Speaker 1: but it's also less likely to have fabrication errors, and 345 00:21:43,080 --> 00:21:46,680 Speaker 1: errors can be both costly and time consuming to address, 346 00:21:46,720 --> 00:21:50,280 Speaker 1: So you have to quantify all these variables and use 347 00:21:50,359 --> 00:21:54,040 Speaker 1: them as constraints to start figuring out your men maxing approach. 348 00:21:54,119 --> 00:21:58,400 Speaker 1: Here line, your programming simply looks for the optimum value 349 00:21:58,560 --> 00:22:01,920 Speaker 1: of a linear expression, and depending on the problem you're 350 00:22:01,960 --> 00:22:06,280 Speaker 1: trying to solve, like maximizing profit versus minimizing costs, you're 351 00:22:06,280 --> 00:22:09,800 Speaker 1: either looking for the highest value being optimum or the 352 00:22:09,800 --> 00:22:12,639 Speaker 1: lowest value being optimum. Like with costs, you want that 353 00:22:12,680 --> 00:22:14,840 Speaker 1: to be the lowest, and you have to look at 354 00:22:14,880 --> 00:22:19,119 Speaker 1: what constraints are at play with any given expression. So 355 00:22:19,200 --> 00:22:23,359 Speaker 1: Danzig's approach to linear programming, called the simplex method, was 356 00:22:23,440 --> 00:22:27,639 Speaker 1: efficient and elegant and far more simplified than other methodologies 357 00:22:27,680 --> 00:22:31,000 Speaker 1: attempting to kind of do the same thing around that time. 358 00:22:31,080 --> 00:22:34,359 Speaker 1: But it also had some limitations, and that's because the 359 00:22:34,400 --> 00:22:38,040 Speaker 1: real world isn't as simple as math tends to be. 360 00:22:38,359 --> 00:22:42,520 Speaker 1: Like math tends to be pretty, you know, firm in 361 00:22:42,560 --> 00:22:44,320 Speaker 1: the grand scheme of things, in the world is a 362 00:22:44,320 --> 00:22:48,280 Speaker 1: little more wibbly wobbly. So a linear programming solution only 363 00:22:48,280 --> 00:22:52,600 Speaker 1: works if the various relationships between the different elements like 364 00:22:52,680 --> 00:22:55,520 Speaker 1: the requirements and the restrictions and the constraints that you've 365 00:22:55,560 --> 00:22:57,760 Speaker 1: set up with this problem. It only works if all 366 00:22:57,800 --> 00:23:01,040 Speaker 1: of those relationships are linear or other words, for a 367 00:23:01,040 --> 00:23:04,840 Speaker 1: given change in one variable, we see a given change 368 00:23:04,960 --> 00:23:08,800 Speaker 1: in other variables, and that is super vague. So we're 369 00:23:08,800 --> 00:23:11,400 Speaker 1: going to talk about two variables. Will reduce it down 370 00:23:11,400 --> 00:23:14,840 Speaker 1: to that. So we'll use the classic X and Y 371 00:23:14,920 --> 00:23:17,720 Speaker 1: as our variables. Those can stand in for all sorts 372 00:23:17,720 --> 00:23:21,520 Speaker 1: of different values. And let's say that we see there's 373 00:23:21,520 --> 00:23:24,520 Speaker 1: a relationship between X and Y, and that if the 374 00:23:24,600 --> 00:23:29,600 Speaker 1: value of X changes from one to two, we then 375 00:23:29,640 --> 00:23:34,040 Speaker 1: see that the value of hy goes from three to nine. Well, 376 00:23:34,040 --> 00:23:36,359 Speaker 1: that doesn't tell us anything on its own, right. We 377 00:23:36,440 --> 00:23:39,320 Speaker 1: just know that if x is one, y is three. 378 00:23:39,400 --> 00:23:42,360 Speaker 1: If x is two, y is nine. If we then 379 00:23:42,400 --> 00:23:46,879 Speaker 1: see that if x is three, then why is fifteen? 380 00:23:47,400 --> 00:23:52,200 Speaker 1: And when x is four, why is twenty one? We 381 00:23:52,359 --> 00:23:55,600 Speaker 1: start to see a linear relationship because each time x 382 00:23:55,640 --> 00:23:59,679 Speaker 1: increases by one, Y increases by six, the rate of 383 00:23:59,720 --> 00:24:05,080 Speaker 1: increase for each variable is linear. It's it's not like 384 00:24:05,119 --> 00:24:08,000 Speaker 1: the rate of increase doesn't change. So we've got this 385 00:24:08,119 --> 00:24:14,040 Speaker 1: linear relationship here. We can contrast this with exponential relationships, 386 00:24:14,080 --> 00:24:17,879 Speaker 1: in which we see not a constant increase but a 387 00:24:17,960 --> 00:24:22,359 Speaker 1: constant ratio in successive terms in one variable when you 388 00:24:22,480 --> 00:24:25,439 Speaker 1: change another. So in this case, let's say that we 389 00:24:25,520 --> 00:24:28,680 Speaker 1: find out then when X is one, why is three? 390 00:24:29,320 --> 00:24:33,160 Speaker 1: When X is two, why is nine? When X is three, 391 00:24:33,720 --> 00:24:37,000 Speaker 1: why is twenties seven? Now we see that why is 392 00:24:37,000 --> 00:24:42,000 Speaker 1: not increasing by six each time. We're seeing that the 393 00:24:42,080 --> 00:24:46,000 Speaker 1: value of why is multiplied by three each time X 394 00:24:46,000 --> 00:24:48,760 Speaker 1: goes up one. So we're seeing there's a constant ratio 395 00:24:49,000 --> 00:24:52,760 Speaker 1: of change with why with regard to X. This gets 396 00:24:52,840 --> 00:24:56,959 Speaker 1: into an exponential relationship. So when someone describes something as 397 00:24:57,000 --> 00:25:02,439 Speaker 1: having exponential growth, what this is supposed to mean is 398 00:25:02,480 --> 00:25:06,439 Speaker 1: that you should see a rate of growth that is 399 00:25:06,520 --> 00:25:11,159 Speaker 1: increasing by some exponent per given unit of time. So 400 00:25:11,200 --> 00:25:14,320 Speaker 1: it's not just that the thing is growing. In fact, 401 00:25:14,320 --> 00:25:17,520 Speaker 1: it's not even that the thing is growing quickly. It's 402 00:25:17,600 --> 00:25:21,160 Speaker 1: that the thing is growing faster as time goes on, 403 00:25:21,320 --> 00:25:25,400 Speaker 1: so that you would say today it's growing, you know, say, 404 00:25:25,400 --> 00:25:28,000 Speaker 1: twice as fast as it was growing yesterday, and tomorrow 405 00:25:28,040 --> 00:25:31,240 Speaker 1: it will grow twice as fast as it was growing today. 406 00:25:31,400 --> 00:25:34,199 Speaker 1: And a lot of people use this phrase incorrectly. We 407 00:25:34,280 --> 00:25:39,200 Speaker 1: often really just mean yo, that thing is growing wicked fast, 408 00:25:39,880 --> 00:25:42,960 Speaker 1: But we don't necessarily mean yo, that thing is growing 409 00:25:43,000 --> 00:25:45,399 Speaker 1: wicked fast, and the rate of growth increases by a 410 00:25:45,440 --> 00:25:51,160 Speaker 1: constant amount over time, so you know, it's it's an 411 00:25:51,160 --> 00:25:54,560 Speaker 1: important distinction to make. Anyway, that was a bit of 412 00:25:54,600 --> 00:25:57,560 Speaker 1: a tangent to say that linear programming works if the 413 00:25:57,680 --> 00:26:01,520 Speaker 1: relationships between all the variables is in fact linear. But 414 00:26:01,800 --> 00:26:05,760 Speaker 1: if if it's not, if the relationship says exponential or 415 00:26:05,840 --> 00:26:10,800 Speaker 1: logarithmic or anything like that, linear programming doesn't apply. And 416 00:26:11,119 --> 00:26:14,480 Speaker 1: the real world is pretty darn complicated. So linear programming 417 00:26:14,480 --> 00:26:17,560 Speaker 1: relies on sort of kind of dumbing down what's really 418 00:26:17,560 --> 00:26:20,119 Speaker 1: going on in the real world. Two. Again, more of 419 00:26:20,160 --> 00:26:23,400 Speaker 1: an approximation, and the solution that you arrive at might 420 00:26:23,440 --> 00:26:26,760 Speaker 1: not be the ideal solution, but it might be good enough, 421 00:26:26,840 --> 00:26:29,800 Speaker 1: depending upon what it is you're trying to do. Another 422 00:26:29,840 --> 00:26:33,160 Speaker 1: limitation of linear programming is that as you add more 423 00:26:33,240 --> 00:26:37,119 Speaker 1: variables to a problem. This is specific to the simplex method. 424 00:26:37,160 --> 00:26:40,840 Speaker 1: As you add more variables, well, it grows more difficult 425 00:26:40,880 --> 00:26:44,879 Speaker 1: to lay out in a linear fashion. You're you're adding 426 00:26:44,920 --> 00:26:51,560 Speaker 1: more uncertainty, and the methodology has trouble dealing with additional uncertainty. 427 00:26:51,600 --> 00:26:56,000 Speaker 1: Perhaps ironically, the complexity of the linear function would grow 428 00:26:56,280 --> 00:27:00,680 Speaker 1: exponentially as more variables joined a problem, so the process 429 00:27:01,080 --> 00:27:05,240 Speaker 1: would be unsuitable for certain subsets of computational problems, because 430 00:27:05,280 --> 00:27:07,560 Speaker 1: they just would get so complex that even the most 431 00:27:07,560 --> 00:27:10,960 Speaker 1: advanced computers in the world wouldn't be able to handle them. 432 00:27:11,040 --> 00:27:15,520 Speaker 1: Later on, other mathematicians would propose algorithms that could compensate 433 00:27:15,640 --> 00:27:19,920 Speaker 1: for this particular limitation of the simplex method. For example, 434 00:27:20,000 --> 00:27:23,760 Speaker 1: there are polynomial time algorithms, but we're gonna leave that 435 00:27:23,800 --> 00:27:26,840 Speaker 1: for the time being, because ain't no way I'm going 436 00:27:26,880 --> 00:27:30,800 Speaker 1: to get that right anyway. I wanted to talk about 437 00:27:30,880 --> 00:27:34,359 Speaker 1: those two algorithms, in particular, the metropolis algorithm and the 438 00:27:34,400 --> 00:27:38,240 Speaker 1: simplex method, because they are the foundation for a lot 439 00:27:38,320 --> 00:27:41,160 Speaker 1: of work that's been done in computer science. But let's 440 00:27:41,200 --> 00:27:45,239 Speaker 1: get some really basic ideas in with the next one. 441 00:27:45,359 --> 00:27:50,000 Speaker 1: Let's talk about sorting. Sorting is all about arranging a 442 00:27:50,119 --> 00:27:54,400 Speaker 1: list of things in order with regard to some specific 443 00:27:54,640 --> 00:27:59,120 Speaker 1: feature of those things. That seems pretty basic, right, I Mean, 444 00:27:59,880 --> 00:28:01,920 Speaker 1: there's a real world example that I think most of 445 00:28:02,000 --> 00:28:04,360 Speaker 1: us have had in the past, which is that let's 446 00:28:04,400 --> 00:28:07,560 Speaker 1: say you're looking at an online store and you're searching 447 00:28:07,600 --> 00:28:12,240 Speaker 1: for a specific product or specific type of product. Let's 448 00:28:12,240 --> 00:28:15,600 Speaker 1: say it's a blender. Because I had to do this recently, right, 449 00:28:16,119 --> 00:28:18,840 Speaker 1: So you go to some online store and you're searching 450 00:28:18,840 --> 00:28:21,840 Speaker 1: for blenders and you get results, Well, you might actually 451 00:28:21,840 --> 00:28:24,320 Speaker 1: want to sort those results by a specific way. Maybe 452 00:28:24,320 --> 00:28:26,080 Speaker 1: you want to sort it by price, and you want 453 00:28:26,080 --> 00:28:28,719 Speaker 1: to go low too high because you have a specific budget, 454 00:28:28,760 --> 00:28:31,080 Speaker 1: so you just want to look at, you know, blenders 455 00:28:31,080 --> 00:28:34,720 Speaker 1: that are an x price or less. Maybe you want 456 00:28:34,720 --> 00:28:37,320 Speaker 1: to sort it by high price too low because maybe 457 00:28:37,320 --> 00:28:39,600 Speaker 1: you're a fat cat tycoon type and you're just thinking, 458 00:28:39,640 --> 00:28:42,800 Speaker 1: I want whatever is the most expensive. Or maybe you 459 00:28:42,840 --> 00:28:45,880 Speaker 1: want to sort the results by customer review because we 460 00:28:45,960 --> 00:28:49,560 Speaker 1: know price and quality don't always go hand in hand. 461 00:28:50,240 --> 00:28:52,480 Speaker 1: Maybe you just want to look at all the blenders 462 00:28:52,480 --> 00:28:54,600 Speaker 1: in alphabetical order, or maybe you want to look at 463 00:28:54,640 --> 00:28:58,520 Speaker 1: them in a reverse alphabetical order. You do you. Sorting 464 00:28:58,680 --> 00:29:02,040 Speaker 1: is one of those most base sick functions and heavily 465 00:29:02,120 --> 00:29:06,240 Speaker 1: studied concepts within computer science, so much so that a 466 00:29:06,320 --> 00:29:12,560 Speaker 1: lot of programming language libraries have sorting functions built into them. 467 00:29:12,680 --> 00:29:15,360 Speaker 1: But it's still one of those things that people look 468 00:29:15,360 --> 00:29:18,560 Speaker 1: at to see if there are better ways to sort 469 00:29:19,080 --> 00:29:22,960 Speaker 1: various types of data, particularly as you get into a 470 00:29:23,080 --> 00:29:28,200 Speaker 1: larger number of of sortable features um and it becomes 471 00:29:28,200 --> 00:29:32,000 Speaker 1: really important. So let's take Google's search algorithm for example. 472 00:29:32,840 --> 00:29:35,720 Speaker 1: Now that name suggests that the algorithm we're talking about 473 00:29:35,760 --> 00:29:38,680 Speaker 1: is related to the process of searching the web for 474 00:29:38,760 --> 00:29:41,760 Speaker 1: pages that relate to a given search query, and in fact, 475 00:29:41,760 --> 00:29:45,160 Speaker 1: Google does have a search algorithm that does this, But 476 00:29:45,440 --> 00:29:47,360 Speaker 1: most of the time I hear people talking about the 477 00:29:47,400 --> 00:29:52,200 Speaker 1: search algorithm, they actually mean that the algorithm that Google 478 00:29:52,280 --> 00:29:56,640 Speaker 1: relies upon to determine what the order of search results 479 00:29:56,680 --> 00:29:59,240 Speaker 1: are going to be that a person sees when they 480 00:29:59,280 --> 00:30:02,240 Speaker 1: search for, you know, whatever it might be. This is 481 00:30:02,240 --> 00:30:06,680 Speaker 1: critically important because multiple studies have shown that most people 482 00:30:06,880 --> 00:30:10,080 Speaker 1: never bother to go beyond the first page of search results, 483 00:30:10,600 --> 00:30:13,360 Speaker 1: which means that Google really needs to do its best 484 00:30:13,520 --> 00:30:17,080 Speaker 1: to make sure that the most relevant results to any 485 00:30:17,240 --> 00:30:21,520 Speaker 1: given search query show up toward the top of this list, 486 00:30:21,600 --> 00:30:25,000 Speaker 1: because most people are never going to bother going any 487 00:30:25,040 --> 00:30:27,959 Speaker 1: further than that. And if those people decide that Google 488 00:30:28,000 --> 00:30:31,800 Speaker 1: search results just aren't any good, they could conceivably use 489 00:30:31,880 --> 00:30:34,840 Speaker 1: some other search engine, and let me tell you, Google 490 00:30:35,040 --> 00:30:39,800 Speaker 1: hates that idea. So Google's goal is to present to 491 00:30:39,960 --> 00:30:43,520 Speaker 1: users search results that are most likely going to meet 492 00:30:43,680 --> 00:30:47,520 Speaker 1: whatever their needs are based on their search criteria and 493 00:30:47,600 --> 00:30:51,320 Speaker 1: way back in the day, Google relied pretty much solely 494 00:30:51,440 --> 00:30:55,520 Speaker 1: on an algorithm called page rank uh, and from what 495 00:30:55,560 --> 00:30:58,720 Speaker 1: I understand, Google still relies on page rank, but also 496 00:30:58,800 --> 00:31:03,560 Speaker 1: makes use of several other algorithms to augment page drink. 497 00:31:04,200 --> 00:31:07,520 Speaker 1: But the page drink algorithm would take a ton of 498 00:31:07,560 --> 00:31:12,440 Speaker 1: stuff into account in the process of determining where within 499 00:31:12,480 --> 00:31:16,000 Speaker 1: a list of search results any given example should appear. 500 00:31:16,640 --> 00:31:21,480 Speaker 1: So let's say that I'm searching for blenders on Google 501 00:31:22,080 --> 00:31:26,840 Speaker 1: for some reason, and the search algorithm has gone out 502 00:31:26,920 --> 00:31:30,440 Speaker 1: and indexed a ton of web pages that deal with blenders. 503 00:31:31,040 --> 00:31:34,760 Speaker 1: Let's say that one of those results is in a 504 00:31:34,840 --> 00:31:38,520 Speaker 1: blog post that isn't that old, it's fairly recent but 505 00:31:38,800 --> 00:31:43,080 Speaker 1: from a mostly unknown source, and very few other documents 506 00:31:43,080 --> 00:31:47,960 Speaker 1: are linking into this blog. Well, chances are that search 507 00:31:47,960 --> 00:31:52,240 Speaker 1: result would appear really far down on the list, probably 508 00:31:52,680 --> 00:31:56,320 Speaker 1: pages and pages and pages down on the results. But 509 00:31:56,360 --> 00:31:59,080 Speaker 1: then let's say that there's another web page that belongs 510 00:31:59,120 --> 00:32:02,680 Speaker 1: to an estab abolished entity, one that has a good reputation, 511 00:32:02,800 --> 00:32:05,080 Speaker 1: it's been around for a while, and there are a 512 00:32:05,080 --> 00:32:10,280 Speaker 1: ton of other pages that link to this particular website. Well, 513 00:32:10,320 --> 00:32:13,760 Speaker 1: that one would probably rank fairly high on the list. 514 00:32:14,760 --> 00:32:19,000 Speaker 1: So The page rank algorithm essentially assigns a score to 515 00:32:19,120 --> 00:32:22,440 Speaker 1: each search result, and the value of that score depends 516 00:32:22,480 --> 00:32:25,200 Speaker 1: upon lots of stuff I mentioned, as well as tons 517 00:32:25,240 --> 00:32:28,520 Speaker 1: of other variables, and these variables can either boost a 518 00:32:28,560 --> 00:32:31,920 Speaker 1: score higher or it can knock some points off. And 519 00:32:31,960 --> 00:32:35,040 Speaker 1: then page rank would take all these different search results 520 00:32:35,080 --> 00:32:41,600 Speaker 1: and order them based upon those scores. Essentially really oversimplifying here, 521 00:32:42,040 --> 00:32:44,880 Speaker 1: but the idea was that the more reliable and therefore 522 00:32:45,040 --> 00:32:48,960 Speaker 1: relevant results would likely be the ones that were the 523 00:32:49,000 --> 00:32:52,520 Speaker 1: most popular. So all those links that aimed at a 524 00:32:52,560 --> 00:32:55,800 Speaker 1: page would count for a lot. If you happen to 525 00:32:55,880 --> 00:33:00,200 Speaker 1: run the definitive page on Blenders and everyone was linking you, 526 00:33:00,200 --> 00:33:05,760 Speaker 1: you that would boost your page links score significantly. Now, clearly, 527 00:33:06,200 --> 00:33:10,400 Speaker 1: just because something is popular doesn't necessarily mean it's the 528 00:33:10,480 --> 00:33:16,560 Speaker 1: most relevant or valuable thing, but it's generally more true 529 00:33:16,600 --> 00:33:20,239 Speaker 1: than it isn't true. It might not always be the 530 00:33:20,280 --> 00:33:24,720 Speaker 1: absolute best result, but it might be reliably relevant, and 531 00:33:24,800 --> 00:33:28,600 Speaker 1: that was what was important to Google and to Google's users. Again, 532 00:33:28,880 --> 00:33:32,160 Speaker 1: it just needs to be good enough. So the page 533 00:33:32,240 --> 00:33:35,960 Speaker 1: rank algorithm was using a pretty complex sorting method to 534 00:33:36,000 --> 00:33:39,680 Speaker 1: determine which results should be the most visible. You can 535 00:33:39,840 --> 00:33:43,600 Speaker 1: of course page through search results. You don't have to 536 00:33:43,640 --> 00:33:47,520 Speaker 1: go with whichever ones are on page one. And in theory, 537 00:33:48,080 --> 00:33:52,280 Speaker 1: if you keep on scrolling through, going to page after 538 00:33:52,320 --> 00:33:56,680 Speaker 1: page after page of search results, then over time you 539 00:33:56,720 --> 00:33:59,560 Speaker 1: should see that the results you're getting are not as 540 00:33:59,600 --> 00:34:02,600 Speaker 1: relevant it as those that appeared earlier on the list, 541 00:34:02,880 --> 00:34:06,720 Speaker 1: assuming everything is working properly. Again, this doesn't always happen, 542 00:34:07,240 --> 00:34:12,080 Speaker 1: but generally it's all it holds true. And yeah, I'm 543 00:34:12,200 --> 00:34:16,800 Speaker 1: drastically oversimplifying. You could teach an entire computer science course 544 00:34:17,080 --> 00:34:20,879 Speaker 1: on the page rink algorithm and how it works. We're 545 00:34:20,920 --> 00:34:22,799 Speaker 1: not going to do that. I would just get it 546 00:34:22,880 --> 00:34:26,640 Speaker 1: wrong anyway. Speaking of search, however, let's talk about a 547 00:34:26,760 --> 00:34:30,839 Speaker 1: much simpler form of search that's based on a basic algorithm, 548 00:34:30,840 --> 00:34:34,840 Speaker 1: and this is called binary search. This is a process 549 00:34:34,880 --> 00:34:37,200 Speaker 1: that's meant to decrease the amount of time it takes 550 00:34:37,239 --> 00:34:42,280 Speaker 1: to search for a specific value within a sordid array 551 00:34:42,520 --> 00:34:45,440 Speaker 1: of values. Alright, So let's say that you've got a 552 00:34:45,560 --> 00:34:51,880 Speaker 1: really big array or list of entries, right, and it's massive, 553 00:34:52,360 --> 00:34:56,480 Speaker 1: and you're searching for a specific target that has a 554 00:34:56,520 --> 00:35:02,439 Speaker 1: specific value associated with it. And computer could go through 555 00:35:02,480 --> 00:35:06,240 Speaker 1: this list item by item, comparing it with your target 556 00:35:06,560 --> 00:35:08,960 Speaker 1: right and look to see if there's a match. If 557 00:35:08,960 --> 00:35:10,560 Speaker 1: there's not a match, you can go to the next 558 00:35:10,560 --> 00:35:13,480 Speaker 1: item on the list and do that. But if you're 559 00:35:13,480 --> 00:35:16,720 Speaker 1: talking about a truly huge list, this could take ages 560 00:35:16,800 --> 00:35:19,080 Speaker 1: because if it happens to be at the bottom of 561 00:35:19,080 --> 00:35:20,640 Speaker 1: that list, you have to wait for the computer to 562 00:35:20,680 --> 00:35:24,520 Speaker 1: go through every single other entry before it gets there. 563 00:35:25,040 --> 00:35:30,799 Speaker 1: So a binary search cuts this short. It takes a 564 00:35:30,960 --> 00:35:34,080 Speaker 1: value that's in the middle of the array, so like 565 00:35:34,200 --> 00:35:38,400 Speaker 1: halfway down the list. Essentially, it just pulls that value 566 00:35:38,719 --> 00:35:41,040 Speaker 1: and it compares it against your target, the thing that 567 00:35:41,120 --> 00:35:44,640 Speaker 1: you're searching for. And if the array is a hundred 568 00:35:44,680 --> 00:35:47,880 Speaker 1: thousand entries long, it's essentially looking at entry number fifty 569 00:35:48,000 --> 00:35:51,920 Speaker 1: thousand and one. It compares this to your search. And 570 00:35:52,000 --> 00:35:55,440 Speaker 1: let's say the value target of your of your search 571 00:35:55,520 --> 00:36:00,280 Speaker 1: query is lower than the entry that appeared at fifty 572 00:36:00,320 --> 00:36:04,160 Speaker 1: thousand and one. Well, now the binary search just tosses 573 00:36:04,360 --> 00:36:07,840 Speaker 1: everything that's fifty thousand and one or higher on the 574 00:36:07,920 --> 00:36:10,359 Speaker 1: list because the values are only going to go up 575 00:36:10,360 --> 00:36:13,160 Speaker 1: from there, so it can get rid of half the 576 00:36:13,239 --> 00:36:17,239 Speaker 1: list right there. You're left with fifty thousand items in 577 00:36:17,320 --> 00:36:21,879 Speaker 1: this array, and the algorithm repeats this process. It goes 578 00:36:21,960 --> 00:36:25,040 Speaker 1: for an entry smack deb in the middle of the array, 579 00:36:25,160 --> 00:36:28,319 Speaker 1: compares it to the target. If the target's value is 580 00:36:28,440 --> 00:36:34,719 Speaker 1: lower than the middle entry of this array, then you 581 00:36:35,120 --> 00:36:38,200 Speaker 1: you dump everything that's at a higher number than that 582 00:36:39,080 --> 00:36:41,960 Speaker 1: if it's lower or it's higher. Rather, if the target 583 00:36:42,040 --> 00:36:44,399 Speaker 1: value is higher than the middle entry, then you would 584 00:36:44,400 --> 00:36:46,759 Speaker 1: get rid of all the previous ones, like one through 585 00:36:46,800 --> 00:36:49,120 Speaker 1: twenty five thousand. For example, Let's say that you know 586 00:36:50,080 --> 00:36:53,080 Speaker 1: your your target value is higher than the middle entry 587 00:36:53,080 --> 00:36:56,480 Speaker 1: of twenty five and one. It's gonna dump everything from 588 00:36:56,480 --> 00:36:58,920 Speaker 1: one to twenty five thousand and start over again and 589 00:36:59,000 --> 00:37:02,040 Speaker 1: half it again again. I'm kind of oversimplifying here, but 590 00:37:02,080 --> 00:37:04,800 Speaker 1: the idea of binary search is that rather than go 591 00:37:04,880 --> 00:37:09,520 Speaker 1: through every single entry, it keeps cutting this array in half, 592 00:37:09,960 --> 00:37:13,319 Speaker 1: comparing it with the target, and doing it again, which 593 00:37:13,320 --> 00:37:16,440 Speaker 1: reduces the number of times it takes to find the 594 00:37:16,480 --> 00:37:19,960 Speaker 1: specific answer. UH. You might have thought of the like 595 00:37:20,000 --> 00:37:23,520 Speaker 1: the the experiment where you think about you're given two 596 00:37:23,560 --> 00:37:26,560 Speaker 1: pennies on day one, and the next day you're given 597 00:37:26,600 --> 00:37:29,960 Speaker 1: four pennies or cents if you prefer two cents. The 598 00:37:29,960 --> 00:37:31,640 Speaker 1: next day you get four cents, the next day you 599 00:37:31,680 --> 00:37:35,359 Speaker 1: get eight cents and it doubles, and pretty quickly you 600 00:37:35,440 --> 00:37:37,719 Speaker 1: see how that doubling can actually start to amount to 601 00:37:37,800 --> 00:37:40,480 Speaker 1: what we would consider, you know, like quote unquote real money, 602 00:37:40,800 --> 00:37:44,120 Speaker 1: the same sort of thing. By by having an array 603 00:37:44,239 --> 00:37:47,759 Speaker 1: over and over again, you very quickly whittle down the 604 00:37:47,760 --> 00:37:49,839 Speaker 1: stuff you have to go through and it speeds up 605 00:37:49,880 --> 00:37:52,680 Speaker 1: the process of searching for a specific value within a 606 00:37:52,840 --> 00:37:58,280 Speaker 1: huge UH data list. Binary search is just one form 607 00:37:58,320 --> 00:38:02,080 Speaker 1: of search for for various data constructs. There are lots 608 00:38:02,080 --> 00:38:06,240 Speaker 1: of others. For example, there's depth first search and breadth 609 00:38:06,440 --> 00:38:09,520 Speaker 1: first search. I won't get too deep into this but 610 00:38:09,960 --> 00:38:12,799 Speaker 1: because it gets really technical, but I can describe what's 611 00:38:12,920 --> 00:38:16,640 Speaker 1: what's happening here from a high level. So these search 612 00:38:16,680 --> 00:38:20,640 Speaker 1: functions are used for data structures that are that consists 613 00:38:20,680 --> 00:38:24,000 Speaker 1: of nodes. And this is easier to understand if we 614 00:38:24,160 --> 00:38:26,680 Speaker 1: use an analogy. And I want you to think of 615 00:38:26,719 --> 00:38:30,279 Speaker 1: a Choose your own Adventure book in case you're not 616 00:38:30,360 --> 00:38:33,600 Speaker 1: familiar with those. These are books where you would read 617 00:38:33,640 --> 00:38:35,360 Speaker 1: a page and at the end of the page you 618 00:38:35,400 --> 00:38:37,720 Speaker 1: would actually be given a choice, like you could choose 619 00:38:38,000 --> 00:38:41,600 Speaker 1: what the character you're reading about would do next, So 620 00:38:42,040 --> 00:38:44,320 Speaker 1: you might get to the end of the first page 621 00:38:44,320 --> 00:38:48,600 Speaker 1: of like a mystery book, and the instruction might say, 622 00:38:48,719 --> 00:38:51,479 Speaker 1: if you want your protagonists to go down the hall, 623 00:38:51,880 --> 00:38:54,600 Speaker 1: turn to page eight. If you want her to shut 624 00:38:54,600 --> 00:38:57,759 Speaker 1: a door and walk away, turn to page twenty three, 625 00:38:58,160 --> 00:38:59,959 Speaker 1: and you would make your choice, turn to that page 626 00:39:00,160 --> 00:39:03,040 Speaker 1: and continue the story that way. And so the story branches, 627 00:39:03,840 --> 00:39:07,520 Speaker 1: and you've got these branching pathways. Well. Depth first and 628 00:39:07,600 --> 00:39:12,800 Speaker 1: breadth first searches explore nodes in different ways. A depth 629 00:39:12,960 --> 00:39:17,719 Speaker 1: first search follows each branched path all the way down 630 00:39:17,760 --> 00:39:21,320 Speaker 1: from start to the end of that one branch, before 631 00:39:21,440 --> 00:39:24,759 Speaker 1: moving on to look at a different branch. So, in 632 00:39:24,800 --> 00:39:27,520 Speaker 1: our example, would the Choose your Own Adventure book, a 633 00:39:27,600 --> 00:39:31,080 Speaker 1: depth first search would go to page eight to follow 634 00:39:31,480 --> 00:39:36,040 Speaker 1: your protagonist down the hall. Then whatever the options were 635 00:39:36,080 --> 00:39:37,440 Speaker 1: at the end of that, it would go with the 636 00:39:37,480 --> 00:39:41,360 Speaker 1: first option, continue and doing this all the time until 637 00:39:41,400 --> 00:39:43,600 Speaker 1: you get to the end of that pathway. Then it 638 00:39:43,600 --> 00:39:46,320 Speaker 1: would come back up to the next most recent branch, 639 00:39:46,440 --> 00:39:48,200 Speaker 1: follow that all the way to the end, and so 640 00:39:48,280 --> 00:39:52,560 Speaker 1: on until it had searched through every possible pathway in 641 00:39:52,640 --> 00:39:56,040 Speaker 1: this this uh, this graph is what we would call 642 00:39:56,080 --> 00:40:03,080 Speaker 1: it breath search. Instead, progress is equally across all possible paths. 643 00:40:03,120 --> 00:40:06,440 Speaker 1: So breath search would mean that you would go to 644 00:40:06,560 --> 00:40:09,920 Speaker 1: page eight, and let's say at the end of page eight, 645 00:40:09,960 --> 00:40:12,440 Speaker 1: it says you can then turn to page seventeen or 646 00:40:12,520 --> 00:40:14,920 Speaker 1: page fifty two to make your next choice. But instead 647 00:40:14,920 --> 00:40:17,839 Speaker 1: of continuing down that pathway, you back up to your 648 00:40:17,840 --> 00:40:21,000 Speaker 1: starting position and then you go down to page twenty three. 649 00:40:21,040 --> 00:40:22,799 Speaker 1: You know, the other option where you would close the 650 00:40:22,800 --> 00:40:25,400 Speaker 1: door and walk away. You would read that maybe at 651 00:40:25,400 --> 00:40:27,680 Speaker 1: the end of that page it says you can choose 652 00:40:27,680 --> 00:40:30,880 Speaker 1: to either go to page three or to page forty six. Well, 653 00:40:31,080 --> 00:40:33,399 Speaker 1: then you would go back to your your first branch. 654 00:40:33,480 --> 00:40:37,920 Speaker 1: You would go down the list of pages seventeen and 655 00:40:38,000 --> 00:40:41,239 Speaker 1: fifty two and three and forty six, maybe those all 656 00:40:41,360 --> 00:40:44,319 Speaker 1: end in different choices. You would then do all of 657 00:40:44,360 --> 00:40:46,760 Speaker 1: those across the board next, so you're you're searching across 658 00:40:46,840 --> 00:40:51,279 Speaker 1: the width of the graph the breadth of it. Both 659 00:40:51,360 --> 00:40:54,720 Speaker 1: are valid forms of searching, and the method used typically 660 00:40:54,719 --> 00:40:57,319 Speaker 1: depends upon the type of data being searched and what 661 00:40:57,360 --> 00:41:00,040 Speaker 1: you're trying to do. We've got a lot more to 662 00:41:00,120 --> 00:41:03,799 Speaker 1: cover with algorithms, but I feel like I'm gonna have 663 00:41:03,960 --> 00:41:07,799 Speaker 1: to give you guys a break, So let's do that 664 00:41:07,840 --> 00:41:10,400 Speaker 1: really quick, and I'll just give you a very short 665 00:41:10,440 --> 00:41:14,080 Speaker 1: example following, and then we'll pick up back up with 666 00:41:14,080 --> 00:41:17,000 Speaker 1: algorithms again in a future episode. But first let's take 667 00:41:17,040 --> 00:41:27,440 Speaker 1: this quick break, all right. I know I've waxed poetic 668 00:41:27,480 --> 00:41:30,400 Speaker 1: about algorithms so much so that this episode is running 669 00:41:30,440 --> 00:41:34,080 Speaker 1: longer than I anticipated. I have a whole extra section 670 00:41:34,760 --> 00:41:39,480 Speaker 1: to talk about with algorithms, including things that are related 671 00:41:39,520 --> 00:41:44,080 Speaker 1: to algorithms but aren't necessarily specifically algorithms, stuff like hashing 672 00:41:44,160 --> 00:41:47,239 Speaker 1: and Markov models and things of that nature. But I 673 00:41:47,280 --> 00:41:49,680 Speaker 1: want to finish up with one that I think is 674 00:41:49,760 --> 00:41:53,560 Speaker 1: kind of fun. And this is called the Doomsday rule. 675 00:41:53,719 --> 00:41:55,600 Speaker 1: And to be be fair, this is not just a 676 00:41:55,640 --> 00:41:58,400 Speaker 1: computational algorithm. This is something that you can do in 677 00:41:58,440 --> 00:42:01,000 Speaker 1: your head if you learn the rule. I'm not saying 678 00:42:01,000 --> 00:42:03,719 Speaker 1: I could do it. I haven't really committed this to 679 00:42:05,200 --> 00:42:08,600 Speaker 1: a memory process yet, but it is possible. And the 680 00:42:08,640 --> 00:42:12,759 Speaker 1: Doomsday rule sounds pretty ominous, however, right. I mean it's 681 00:42:12,760 --> 00:42:15,560 Speaker 1: basically to figure out what day of the week any 682 00:42:15,719 --> 00:42:19,880 Speaker 1: given date is. So if you were an expert with 683 00:42:19,960 --> 00:42:22,799 Speaker 1: the doomsday rule and I asked you, hey, what day 684 00:42:22,800 --> 00:42:27,560 Speaker 1: of the week does June five fall on? You could 685 00:42:27,760 --> 00:42:30,600 Speaker 1: use that rule and say, oh, that's gonna be a Thursday. 686 00:42:31,040 --> 00:42:32,600 Speaker 1: That also, by the way, happens to be the day 687 00:42:32,600 --> 00:42:36,279 Speaker 1: I'll turn fifty. Yikes, man, we're coming up on that one. 688 00:42:36,320 --> 00:42:40,399 Speaker 1: All right, So where did this rule come from? And 689 00:42:40,440 --> 00:42:43,239 Speaker 1: what the heck is this doomsday stuff about? Well, the 690 00:42:43,239 --> 00:42:46,080 Speaker 1: doomsday thing is kind of just a cheeky name, and 691 00:42:46,280 --> 00:42:49,319 Speaker 1: there's all these different ways we could describe that. But 692 00:42:50,239 --> 00:42:53,319 Speaker 1: during any given year, there are certain dates that will 693 00:42:53,360 --> 00:42:55,880 Speaker 1: always share the same day of the week, which is 694 00:42:55,920 --> 00:43:00,000 Speaker 1: no big surprise, right. I mean, you might notice that Christmas, 695 00:43:00,200 --> 00:43:03,160 Speaker 1: that is December twenty falls on the same day of 696 00:43:03,160 --> 00:43:06,080 Speaker 1: the week as New Year's Day for the following year 697 00:43:06,360 --> 00:43:09,600 Speaker 1: that happened, you know, January one. It always is that way. 698 00:43:09,640 --> 00:43:14,600 Speaker 1: But with the doomsday rule, the dates for that are 699 00:43:14,680 --> 00:43:18,560 Speaker 1: called doomsdays. Are things like April four or four four, 700 00:43:19,120 --> 00:43:24,000 Speaker 1: June six that's six six, August eight that's eight eight, 701 00:43:24,560 --> 00:43:27,520 Speaker 1: and you know, so on like October tenth, that's ten ten. 702 00:43:28,520 --> 00:43:32,919 Speaker 1: The anchor day are called these are anchor days, they're 703 00:43:32,920 --> 00:43:39,400 Speaker 1: called doomsdays. Um, they change with each year or with 704 00:43:39,560 --> 00:43:42,640 Speaker 1: leap years. The anchor day actually leaps a year. But 705 00:43:43,040 --> 00:43:45,080 Speaker 1: once you know that day. You know, it's the same 706 00:43:45,120 --> 00:43:48,560 Speaker 1: for all of those dates. So for one, as I 707 00:43:48,600 --> 00:43:54,279 Speaker 1: record this, this year's doomsday is or anchor day is 708 00:43:54,280 --> 00:43:56,440 Speaker 1: a Sunday, So that means every Doomsday is going to 709 00:43:56,480 --> 00:43:59,759 Speaker 1: be a Sunday. So I'm recording this in July with 710 00:44:00,320 --> 00:44:05,080 Speaker 1: our next doomsday being on August eight, So that means 711 00:44:05,120 --> 00:44:09,680 Speaker 1: August eight should be a Sunday. And if you look 712 00:44:09,680 --> 00:44:12,920 Speaker 1: at the calendar, you'll see that, yes, August eight is 713 00:44:12,960 --> 00:44:17,160 Speaker 1: a Sunday. That means that October tenth should be a Sunday, 714 00:44:17,160 --> 00:44:21,520 Speaker 1: that December twelve should be a Sunday. So the doomsday 715 00:44:21,560 --> 00:44:24,080 Speaker 1: rule involves a little bit more than just this, but 716 00:44:24,200 --> 00:44:27,000 Speaker 1: not much more. And this means that if you learn 717 00:44:27,080 --> 00:44:30,879 Speaker 1: the doomsday rule and you have a general idea of 718 00:44:30,920 --> 00:44:34,719 Speaker 1: what the anchor day is for each year, you can 719 00:44:34,800 --> 00:44:38,600 Speaker 1: calculate what in what day of the week any given 720 00:44:38,719 --> 00:44:42,879 Speaker 1: date will fall on, including past years. The guy who 721 00:44:42,920 --> 00:44:46,560 Speaker 1: came up with this was a mathematician named John Conway, 722 00:44:46,600 --> 00:44:50,160 Speaker 1: and reportedly he could give you an answer in less 723 00:44:50,160 --> 00:44:51,960 Speaker 1: than two seconds. If you gave him a date, he 724 00:44:51,960 --> 00:44:53,480 Speaker 1: could tell you what day of the week it was 725 00:44:53,480 --> 00:44:57,040 Speaker 1: going to fall on in two seconds or less. Sadly, 726 00:44:57,120 --> 00:45:00,560 Speaker 1: he passed away last year at the age of eighty 727 00:45:00,560 --> 00:45:05,279 Speaker 1: two after he contracted COVID nineteen. But that doomsday rule 728 00:45:05,360 --> 00:45:07,120 Speaker 1: is one that I think is super cool. I've seen 729 00:45:07,120 --> 00:45:08,880 Speaker 1: people who can do this where you give them a 730 00:45:08,960 --> 00:45:11,000 Speaker 1: date and they're just able to tell you what day 731 00:45:11,000 --> 00:45:13,400 Speaker 1: of the week that falls on, and you can go 732 00:45:13,440 --> 00:45:15,799 Speaker 1: and check it and sure enough they're right. Well, this 733 00:45:15,880 --> 00:45:18,520 Speaker 1: is one process where you can do that. It's not 734 00:45:18,560 --> 00:45:21,240 Speaker 1: the only one, by the way, there are other algorithms 735 00:45:21,320 --> 00:45:24,640 Speaker 1: that also can help you determine what day of the 736 00:45:24,680 --> 00:45:27,960 Speaker 1: week a specific date will fall on. But the doomsday 737 00:45:28,040 --> 00:45:31,319 Speaker 1: rule is is one that works. And again I don't 738 00:45:31,320 --> 00:45:34,319 Speaker 1: have it. Uh. I don't have an expertise in this. 739 00:45:34,480 --> 00:45:37,080 Speaker 1: I haven't practiced it at all, so I can't do it. 740 00:45:37,520 --> 00:45:39,120 Speaker 1: If you came up to me and said, hey, Jonathan 741 00:45:39,680 --> 00:45:42,960 Speaker 1: May first, nineteen, what day of the week was that, 742 00:45:42,960 --> 00:45:46,560 Speaker 1: I'd be like, A, I don't know. Probably A it's 743 00:45:46,600 --> 00:45:50,120 Speaker 1: probably a fine day. I don't I don't know because 744 00:45:50,120 --> 00:45:52,520 Speaker 1: I haven't done this yet. But I think it's really cool. 745 00:45:52,560 --> 00:45:56,239 Speaker 1: I gets it illustrates how for certain types of problems 746 00:45:56,640 --> 00:45:59,840 Speaker 1: you can come up with a mathematical approach to solving 747 00:45:59,840 --> 00:46:03,880 Speaker 1: the problems, and it just is applicable for all problems 748 00:46:03,920 --> 00:46:07,160 Speaker 1: that fall into that category. And that's really the elegant 749 00:46:07,200 --> 00:46:09,680 Speaker 1: and cool thing about algorithms. Also, the other cool thing 750 00:46:09,719 --> 00:46:11,719 Speaker 1: is that people are coming up with new ones all 751 00:46:11,800 --> 00:46:15,680 Speaker 1: the time, and they might be trying to refine earlier 752 00:46:15,719 --> 00:46:19,360 Speaker 1: algorithms to make them even more efficient and effective, or 753 00:46:19,400 --> 00:46:20,839 Speaker 1: they might be trying to come up with all new 754 00:46:20,880 --> 00:46:25,799 Speaker 1: algorithms to take advantage of emerging technology stuff like quantum computing. 755 00:46:26,200 --> 00:46:28,160 Speaker 1: But as I said, I'll have to do another episode 756 00:46:28,160 --> 00:46:31,640 Speaker 1: about algorithms to talk more about it, because this one 757 00:46:31,719 --> 00:46:33,759 Speaker 1: ran longer than I thought. Like I said, I've got 758 00:46:33,760 --> 00:46:36,600 Speaker 1: like three more pages of notes that I wanted to 759 00:46:36,600 --> 00:46:40,680 Speaker 1: go over, but I ran long, So we're gonna cut 760 00:46:40,719 --> 00:46:43,000 Speaker 1: this one short. But we will come back to algorithms 761 00:46:43,040 --> 00:46:45,480 Speaker 1: at some point in the future and talk about some 762 00:46:45,520 --> 00:46:48,560 Speaker 1: related stuff. I really want to talk about hashing, particularly 763 00:46:48,640 --> 00:46:52,279 Speaker 1: as it applies to stuff like bitcoin mining, because that's 764 00:46:52,280 --> 00:46:55,240 Speaker 1: a pretty big deal. If you have suggestions for topics 765 00:46:55,280 --> 00:46:57,839 Speaker 1: I should cover in tech stuff, whether it's something really 766 00:46:57,840 --> 00:47:01,200 Speaker 1: technical or maybe just a goofy thing in tech. It 767 00:47:01,239 --> 00:47:04,400 Speaker 1: could be a person in tech, a company, a specific 768 00:47:04,480 --> 00:47:07,200 Speaker 1: product and you want to know about its history and impact, 769 00:47:07,600 --> 00:47:10,360 Speaker 1: anything like that. Let me know. The best way to 770 00:47:10,360 --> 00:47:12,600 Speaker 1: get in touch with me is over on Twitter. The 771 00:47:12,680 --> 00:47:16,279 Speaker 1: handle we use is tech stuff H s W and 772 00:47:16,360 --> 00:47:24,640 Speaker 1: I'll talk to you again really soon. Tech Stuff is 773 00:47:24,680 --> 00:47:27,800 Speaker 1: an I Heart Radio production. For more podcasts from my 774 00:47:27,960 --> 00:47:31,560 Speaker 1: Heart Radio, visit the i Heart Radio app, Apple Podcasts, 775 00:47:31,680 --> 00:47:33,680 Speaker 1: or wherever you listen to your favorite shows.