In this video, I want to show you how you can use d3 to compute very simple statistics of your data. While those are simply statistics, we often need them in order to help to the transition between the data space to the visual space. They are going to be very helpful, when we are building scales. While it's not that hard to compute those statistics using map, reduce and any other resource that we have in JavaScript, d3 provides some search shortcut that make much easier to deal with, and going to make your code cleaner, when you're writing it. So, that's why I want to show you how to use those functions here. What we have here is a list with the people in our data set. Now, we want to extract this information. So first, we want to extract the sum, what is the sum of all those numbers? Second, the mean of all those numbers. Lastly, we want the extent. The extent means, the minimum and the maximum value that we have here. Again, those values going to be helpful for us when we are building our visualization. So, let's see how we can do it. So, I have here a code that basically loads the data from a data CSV file, and also, the data is loaded, I call my function showData. This function showData goes through each client, and write this client to the screen. That's how we produce this top part of our code. Lastly, we're going to keep calling the write function just to write a line here. Then finally, we're going to write those values. The sum, the mean and the extent to those variables. So, those are the ones that are missing right now. We have zero for all of them, and you want to fix that. So, let us start with sum. How can I get the sum of this data? So, I basically can do d3.sum, and I can tell first, which list I want to sum, and I want to sum my clients. Then finally, I can provide the function that's going to return the value that I want to sum, because remember, client, the element inside this list is an object. I can not sum objects. I can only sum values that are inside them. So, we want to return this value. So again, we're going to use a function here, and as we often do, we're going to use d to represent our data point, and we're going to return the value that we want to sum. So, in this case, we want to sum the weight. So, I'm just going to do write d, and we're going to return the weight. So, this is my function and it's part of our function here on the top. I just break the line so it's easier to read. But you see that now, we get the sum in our page. So, the next step is getting the mean. So, the job is exactly the same? So, we do d3, we want the mean, and we want the mean of a list of clients. Finally, we're going to call a function, that's going to receive the data point d, that, again, d is my client, and you're going to return the weight of this client. Now d3 is going to compute the mean of the values that we have on the top. So finally, we are looking for the extent. That is the maximum and the minimum of the data. So, in order to do that, again, the job is the same. So, one of the advantages of this approach is that, it's very consistent the way you compute each of those. You basically change one word, and you get a different statistics. So, we have client, we're going to do exactly the same thing, the weight that is going to return the weight, and you'll see that now I get the minimum weight here, that is 150 here, and 200 there is my maximum value here. So, those are functions that help us to compute statistics. We have a bit more, and especially we have max and mean, if you only want one of those values, and as I said, we're going to be using them to compute and help us to translate data from one domain to another. So, we need them to understand both domains and be able to switch between these two domains. So, they are really important, although they are simply statistics, you can still using d3 just as a short hand in harder than higher having to write your function to sum, or get means of things.