In this video we want to talk about how we can use d3 to compute very simple statistics of your data. So you also of course can do that manually, but d3 provides some helpers that's going to facilitate the process of getting simple information of your data that you can use for your visualization. So, for example, one of these information is what we call data domain. And data domain is the range of values that your data can assume. So if you have a niche, it's basically the minimum and the maximum age that you can have in your data. If you have categorical information, for example, you have states in US, the domain is basically the list of all the states that we have in US. So you want to convert this to get information of this domain so you can use that to create your scales or to create your visualization or map your data from the original domain to the new domain that is what we call an image space. So d3 provides for us, if you want to look in the range of numerical value, two functions. One is the max and the other one is the min. They have exactly the same syntax, we we use them in exactly the same way. The difference is that one is going to return the highest value, the maximal value, and the other one is going to return the minimal value. And the way we use this function is that as first parameter, we pass our data that is often an array, with each element representing one of the elements we want to visualize. And we can pass also an assessor. And this is optional, but most of the time you use it because you want, it's kind of a map, so you're basically taking your element and selecting from your whole data only the thing that you want. So for example if I have a client, I going to use the accessor to select only the age. So, and this concept is used throughout d3 in many other different functions. So you always have a function that is going to receive as parameter of value that is the data that you're looking at and a index that is the position of the data in the least that you are going through. And this is very common and many functions in d3's going to use the same pattern. And how we use it, so for example, here, I am getting the maximal age that I have in my data or the minimal age. I basically can just switch the product mean and the product max by the function that I want, either minimal or the maximal. The rest is still the same. Another option is to use what we call the d3.extent, and in this case, it computes both for us at the same time. So you can just call extent with your data and then use a function in the same way you used before, to select which value of the data we want to use. And d3 is going to return an array, and in this array, the first element is the minimum value and the last element is the maximum value of your data. Besides just getting the maximum and the minimum, you may also want to sum or get a mean of your data in order to mark some points of interest on your visualization. So if you want to do that, they again have the same syntax, we can just switch different functions to get different value. And as max and min, we're going to call this with our data and then we're going to pass some assessor that's going to get which value we want to get the mean from or the sum of. So for example here what I'm doing is that I'm summing all the ages of my data in order to come up with all the additions of them. If you are creating for example a stacked bar chart, you may want this information because you want to stock bars and you need to know what's going to be the highest high of your bars once all of them are one above the other. So simple statistics are useful when we want to create our visualization and especially when we are creating scales. And scales are thing that's going to help us to map our data from the original space to the image space that is the one that we use to visualize. And often, what we need is to either get some maximum or minimum so we can understand the domain of the data. Or get sums and means so we can see the extent if I add all this data together, how much space they going to take on the screen. Or if I take the middle of my data in my distribution where it will going to be. And it will help us with that and also provide many other functions that we can use to compute those statistics.