 So, the notion here is to put randomness into our simulations and we already know a lot about this just from the homework you've been doing. Why do we want randomness in our simulations? For, because there's complexity in the world. Things aren't constants in the real world and so they shouldn't be constants in our simulation. If we know, that's a different question, but if we know the distribution that our data or input data follows, that's great, then we can sample from it from this distribution. This class, but maybe next week or the week after, we'll be looking at how do we know what the distribution is? How do we know that our, for example, that our interarrival times are exponential? Okay, it's a different question. Right now all we know is we need randomness. You saw that when you, for those of you, well, even when you did the uniform distribution, and for those of you who did your, the Excel using the exponential distribution, it was all based on random, the random number generator, which gave you a random number between zero and one, if I'm not mistaken. So that's the first thing, and that's what this lecture really is all about. It's about the base randomness, not about generating various from a particular distribution. We could, although we don't, we could use real randomness in our simulation, right? If you haven't thought about it, you could think about it now. We could use, and in fact, the checkout stands started out that way, where we were using something that was really random, tossing a die, chips in a hat, labeled one to ten. So you can see there are other ideas, a roulette wheel. Generally speaking, when you have a truly random number, there are some real physical process that generates the randomness, radioactive decay, bumping electrons off of a wall or towards a wall. And so it bounces off and measuring the distance from the center or from an edge. Something that results in randomness and that can be measured. That sounds extremely messy and extremely expensive, so you can understand we don't do that. However, we might do that to generate random numbers, right? We've all, if you haven't, you can look it up when you get home, or you are home probably, when you get to a book in either probability or statistics. At the back of the book, there'll be a random numbers table. You probably used it before in your undergraduate studies. What were these, where did these random numbers come from? Well, we know where they came from. They came from the RAND Corporation, which actually used an electronic simulation of a roulette wheel for the randomness, true randomness attached to a computer to generate the measurements, the values. And that wasn't good enough, even though it was truly random. So they had to also test it. And perhaps there was some filtering going on to make sure that extreme values, let's say, you know, weren't left in. There was certain parameters that they needed to match. Your book of random numbers comes from, or the table of random numbers at the back of your book comes from a book that was put out in 1955 by RAND with those random numbers. And in addition, between the late 1940s and on, the RAND Corporation made these random numbers available to people on a magnetic tape. So that, you know, you don't have to actually key in the values from the random number table. And what you see there on the screen is just a clip, a piece of the random number table. And it's grouped in units of five digits. And it looks two dimensional, but it's not two dimensional. It's just a one long stream of random digits. So if you look at the top left, it starts with seven, seven, three, seven, three, five, four, five, nine, six, three and so on, across the row and then in major row order. And all that was was a convenient way of arranging one long stream of random digits. So those, they don't have anything to do with each other it doesn't matter it doesn't matter that they're in groups of five, or that this looks like it's in two dimensions none of that is none of that is important. It's just a stream of random digits. So we could use true randomness. These digits are truly random, we could still get access to it on an electronic, an electronic form. We could use any file with it. Think about why we don't. And I'm not asking people to contribute because we're recording, and I know people may not wish to, but please do feel free if you don't mind to just unmute yourself anytime and jump in, either answer questions or ask your own. So think about it. If we have a file of random numbers or in this case random digits. How do we access it for our simulation program. We would have to read a digit from the file. Maybe we'd have to read a sequence of 10 digits from the file if that's what we need. Use it in the simulation, discard it, and then go to the next one and read another number and use it in the simulation. And you may not realize this, but reading from an external file is extremely expensive it takes a long time. It takes a lot of computer time. And the probably the most expensive thing that you could be doing in the context of, if you're paying for computer time for example. It's very inefficient use of your time. So it we could do it, but now let's move on to look at something that might be almost as good, and sometimes maybe even better. All right, what we actually use are not random numbers even though the function in Excel is called RAND. They're really pseudo random numbers and if you look at the diagram on the slide. That's exactly what a pseudo random number generator does. It outputs a random number. And then uses that random number as input in order to generate the next number and the next number and the next number. So there's a stream of random numbers, each one generating the next. And naturally, it's booted up externally before you get into that loop by a single random number that's used once. And that's called the seed. SEED that should probably be, I should probably put that in the slide shouldn't I. So that random number that's used once as input to the pseudo random number generator is the seed, which then produces the entire stream of random numbers that comes after it. So because if we ever want to duplicate what we've done before, all we have to do is use the same seed, and it will produce the same stream of random numbers every single time. And if we don't want to duplicate what we did before but we want we want true randomness, we just start with a different seed, which has its own issues of course as we know. So, not only are truly random numbers inefficient and more expensive to use, especially when we're talking about computer time, even many simulation programs are, you know, take a very long time. Some of them even have to be run on a supercomputer. However, they're still doable. In addition to that reason, pseudo random numbers are better. Because, well, it's faster, which not only means that I don't have to pay for that lengthy computer time but it's faster. I don't have to wait such a long time for my computer program to run in the programs we've been doing that's not an issue. But in other cases it is. But even more, probably the best reason for using pseudo random numbers is because I can actually not to replicate I can duplicate what I've done before. If I have the same model and the same random numbers, I will get exactly the same thing that I got before. So you're going to say why would I want that. I'm going to get the same thing I got before. There are cases when you would want that suppose I'm planning to renovate my hospital emergency room. Wouldn't it be nice if I could take the customers I had yesterday, do the renovation, and then run the same customers with the same illnesses through the emergency room tomorrow after the renovation and look at the differences. That by by this, this feature of reproducibility. If I use a pseudo random number generator, as opposed to truly random numbers. Certainly, if I use a pseudo random number generator as opposed to just experimenting in the real world. I truthfully with truly random numbers as long as I have saved them in some format, I can reuse them. Sure. A disadvantage of pseudo random numbers, and especially a disadvantage if we want to keep on using a different seed. In order to have to not have the same. The same entities moving through the system at the same rate and at the same time, each time every pseudo random number generator has what's called periodicity. It's a finite period during which every random number generates another new random number, but after a while, it's goes back it cycles back to the beginning. And you have the very same stream of random numbers from that point. Obviously, clearly, that's a problem, especially if you don't know what's going on. Everyone wants to see what a pseudo random number generator looks like. Here's one. It's a simple one and as you can see it's also an old one. It's presumably not what we're using in our calculators in programs in Excel, because there are better more efficient ones, but the nice thing about this is it's simple to do by hand and it's simple to understand. Okay, let's see how it works. It's called middle square. We start with, as always, we start with a random number of a certain number of digits. In this case, we're looking for an end of is even so you know whatever it is, whatever you decide on that you you figure out what your seed will be. So in some random number you can even start with a sequence of random digits and even number of them from the random number table. Take the random number do some arithmetic to it that's what all of these random number generators do. They take the random number do some arithmetic to it and output spit out the next random number in the sequence. In this case, what are we doing we're squaring it. We're adding zeros to the left which we know is doable and doesn't change the value. And we're going to form a sequence we add enough digits to form a sequence of two and digits. So if we have, let's go to the example. If we have 1111 as hard as a wonderful seed right, we have 1111 as our as our first random number. We square it. Get 1234321. That's seven. We put the zero on on the left, which doesn't change things but makes it an eight digit number. And the center is 2343. We take the the middle four digits to create the new random number of four digits. Okay, and the more digits you use obviously the better you'll be especially if you're doing this for cryptography. So this is one that's probably not going to be used because the the periodicity is very small it starts to repeat very quickly. Why couldn't you preview my file. See if I get it now. Yeah. Okay, good. What should a good pseudo random number generator have it's this is pretty much common sense. I think you could figure all of these out on your own. But let's take a look let's go down the list. Be random. Of course they're not going to be random. How do we know that pseudo random numbers are not random. How, how do we know they're not random. Well, if I give you a pseudo random number that goes into the generator, I can predict what the output will be. That's the very definition of relatedness of not being random. If you can predict what your random number will be clearly it's not random if you can compute a random number using a bunch of arithmetic. Clearly it's not random. So our pseudo random numbers aren't really random. That's why they're called pseudo random. They behave like random numbers. All right, I see a chat flashing is that okay. And if any problem with that. Oh, okay. All right. I should learn my lesson. If you see something in the chat, somebody check to see if it's important. And give me Morse code or you can even send me an email I have my phone right here. If you don't want to speak. Okay. All right. So basically pseudo random numbers appear random. They act random. Clearly they should be reproducible because one of the things we liked is the fact that as long as we have the seed. We can produce the same stream of random numbers each and every time every single time. That's not only something we like it's critical, because there's no point in using pseudo random numbers otherwise over truly random numbers it's a huge advantage. We want the algorithm to be fast we want it to work quickly we don't want to have to wait to get the random numbers as you know from working with Excel. Once things get a little bit complicated, even a few seconds of a delay when things are recomputing a noise us. We want to make efficient use of computer resources so it's not only time. There's also space in other words how much storage spaces use where the storage is whenever we say efficient in relation to computer resources we're talking about issues of time and space. We want to make sure that even though we know they will always be cycling there will be periodicity. We want to make sure that the algorithm we use has a long period. So because it's pretty much useless if it does. And we want to make sure that not only do we want numbers to be random but we don't we want them to be distinct we don't want to get the same number over and over again that if that happens that means the whole thing just degenerated. How can we test random numbers. The fact of the matter is that pseudo random numbers are tested when when when someone, let's say we tests a pseudo random number generator for goodness to see how good it is. They're going to be it's going to be tested to see if the numbers are quote unquote random which basically means do they act like random numbers. We know they're not random. But we want to know if they act like random numbers. These these pseudo random number generators do test well. They act like random numbers for the most part there's a little bit of an issue with Excel, at least in the 2010 edition. The interesting thing is that if you do higher level testing, which, of course, we're not doing in this course. But if you ever find yourself in a situation where you are doing higher level testing and by higher level. I mean multi dimensional hyperplane testing. So in other words when we test the stream of random digits or a stream of random numbers. We're testing something linear. Right. But if you take these numbers and look at them in a hyperplane very often patterns emerge. And the people who the mathematicians who study this have basically said, there's no such thing as a truly random pseudo random number generator. But as always what we're looking for is good enough we're looking for it to be good enough random enough. If it passes the tests of randomness, we're happy, then we're good. Okay. So even though so I'm going to move on to.