 Welcome to my lecture on collecting output statistics from a simulation model. It's part of the topic of simulation model implementation, otherwise known as simulation programming. Why do we even think that it's a problem to generate data from our simulation? We do that in anything. Anytime we do any programming at all, we generate data. We have a statistical field experiment. We generate data. Why is simulation so different and so important? Well, sometimes it's easy and we create and output data the same way as we would in anything else, but sometimes it's difficult. And the reason is that with the kind of simulation we're doing in this course, discrete event simulation, we are always assuming that there is a time element. The model is moving over time and some of the statistics we're accumulating, we're accumulating over time and that always makes it a little bit hairier. We'll see how that works. Here you see the different categories of statistics we might be collecting during a simulation run and they're organized by the way they're collected. The counters are just headcounts or nose counts as it says here, like number of arrivals, the number of times something happened, number of times a particular event occurred, number of entities processed. This may be used to count entities passing through a particular point in the model, like maybe the exit. The utilization is the same way the word is used in other areas. It's the fraction of time that a resource is in use. One minus that would be the fraction of time the resource is idle. Tallys, this is where we keep track of discrete values of something. So for example, times in queue. The customer has a waiting time in queue. If we want to generate an average, we have to sum those and divide by the number of customers in the end of the whole thing at the end of the whole run. Not so terrible. The one that needed a whole slide for itself is the one called time dependent counters where the value keeps changing over time and that takes a little bit of a different approach to accumulate the sum. There's a little graph on the slide. The x-axis is time, the run always moves over time from left to right. The y-axis, the height of the graph is the value of a variable like maybe number of customers waiting in the queue. And you see that there are jumps. It's not a smooth curve because this is a discrete event simulation. What you want to do in this case, we need, if we want to get the average as our metric from the run, average number of customers in the queue. That's a time average because it's average number of customers, let's say in any typical minute, average number of customers over in an hour. It's a time value. And in essence, if you look at that, we'll come back to this, but if you look at that graph, if you could sum the area under the graph, you'd have a pretty good, that would be a pretty good way of getting your average. At least get the sum. If you could sum it by taking length times width and adding all of those up, the same way you would with an integral and a smooth curve. But we can do it easier, especially since we have these values generated during the course of the simulation. And we're going to look at an example pretty soon so you can see exactly how that's done. But basically what we're doing here is in order to get a time dependent average as the output from the simulation run, we have to accumulate statistics instead of just counting or tallying. We're getting a weighted average. And it's weighted by the length of time these values have been held. So in the queue, you might have a one person waiting in the queue for three minutes. You might have five people waiting in the queue for five minutes. So we need a weighted average in order to find out on the average, how many people are waiting in the queue. And notice the units will help you out because the units on this average is number of customers per time unit. This is the example we're going to work with over the next few slides. We want to output the average over the course of the simulation run of the number in the queue. We're designating it as number queue or number in queue. And it's the number on the average, how many people are waiting for service over the course of the simulation run. And it's a time average. So take a look here. It might be easier to see here because I'm reducing this figure on the next slide. You start out at empty and idle. We go from time zero to time one point something. It'll be more exact later on, but it doesn't even matter right now. I just want to show you and it's still zero. Then all of a sudden it jumps to one, one person waiting in queue and one person on the Y axis continues with one until two something or until three and then jumps to three, jumps from one to three. Continues with the value of three people in the queue until at some point between four and five, it drops down to two. And it's two for a while until six, it seems. And then it jumps up to three. And this is the very picture of a discrete event system simulation that we've been talking about. So let's see how we work with this. The first thing we do is we create a table. Those are the values, by the way, that created the graph. So don't think I actually figured out the values from the graph, which is a little harder to read. So we start out with this table. We have three columns, the number in the queue, the time that value began and the time that it changed. So there were zero people in the queue between time zero and time 1.2. There was one person in the queue between time 1.2 and three. And moving down, the very last value is there was one person in the queue between time 17.1 and time 18, which presumably is when our data collection ended. Either a simulation ended or we just decided this is as much data as we needed for now. Here's the rest of the table. You may want to pause the PowerPoint or the video depending on how you're reading this and try to do it yourself. Fill out the table yourself or at least give it a little bit more time than you would have just by hanging on the slide and listening to my voice because you may have to focus on this a little bit. The first three columns are from before. Then the column four, and you see how the columns are labeled when we use them. Column four is the time increment. We get that by taking the value in three minus two, column three minus column two. So the time increment is from time zero to time 1.2, which gives you 1.2. The time increment in the next line is between 1.2 and three, which gives you a time increment of 1.8. We need this if we're going to get that weighted average of our values over time. In the next cell, the next column, you see we get area. Remember I said it's kind of like we want to get this sum as our weighted average. So you get the, or four, our weighted average. The area you want is the value of the y variable. In this case, we're looking at the number in the queue times the value in column four, the time increment. If you take each value, multiply it by the time increment, sum all of those up and divide by the amount of time in the system, that's your weighted average. And that's exactly what we need. So in this case, we're not just tallying things. We're not just summing things. We're not just counting things. What we're doing is accumulating. We're accumulating values for a time-based statistic, which is going to be used in a weighted average at the end of the simulation run. Let's take a look at the right. So some examples. Suppose we want to output the average at time 11.2 because these are things we might want to do during the course of a simulation run. Where is 11.2? Time 11.2. That's at the same level. I don't have my rows numbered here, but that's at the same row as the sum 33, 31.0. It ends. 31.0 is the sum for the interval that ends at 11.2. So 31 is the sum. 11.2 is the total amount of time. And remember that 31 included the times. It was the time intervals for the amount of time that each value was in the system, was in the queue, multiplied by the value. So if we take that accumulated sum, that weighted sum, and divide by the total time, we get 2.77. So for that period of time, for 11.2, the average number of customers in the queue was 2.77. Take a look at the values you have there. They go from 0 to 4, 0 to 5. And there's a lot of low ones. There's only 4 in queue only occurs once. So that's not so bad. It sounds kind of reasonable. And the arithmetic probably made sense, but certainly you can do it on your own. Again, I strongly recommend that you pause whatever media you're looking at this on and do the problem on your own. Now, what if I want to, say, average the number, get the average number of customers in the queue for a time that I don't have here, because it was in the middle of a time interval? Well, I prorate it then. I mean, we can figure it out. 10 is in between 8.3 and 11.2. We take 16.5, which is the sum at the end of time 8.3. And then we have five people in queue between 8.3 and 11.2, but we only want 8.3 to 10. And that's how we get that. We divide the whole thing by 10, because that's the total time we're considering. And we get two and a half, two and a half on the average, two and a half people, customers in the queue during those 10 minutes. In this very brief lecture, we've considered that we have to do something different for some of the statistics we're collecting because our simulations move over time. So when we have statistics, values, data values that also change over time where the time interval is important, those are the data-dependent statistics. We have to do things a little bit differently than we would otherwise, and that's what we've looked at here. We've looked at different types of data. Time-dependent statistics is only one of them. And then we looked at an example of how to, or at least how to, your computer program or your simulation software tool would accumulate the data that you need in order to get a time average or any kind of statistic based on time over the course of the simulation run.