# How do I split up a list of data points into invervals and assign values to those intervals?

So I have a data set for chess and our goal is to plot the difference between the rating difference versus white's win rate. I want to subdivide the x-axis into intervals like (-10, 0) (10,20) (20,30) and read the data in the intervals and get the percent of white's win rate over that inverval. Our goal is to plot sort of like a step function for each of the intervals and eventually create a linear regression with the values of each interval.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dunlop Oct 29 '19 at 20:38
• Can you give some example data that people could work with? This would be helpful in terms of getting an answer. Also useful is to show what code you have already tried – Dunlop Oct 29 '19 at 20:39

You can use WeightedData and Histogram as follows:

First some fake win/loss and rating difference data:

SeedRandom[1]
whiteWinLoss = RandomInteger[1, 200];
ratingdiff = Subtract @@ RandomInteger[100, {2, 200}];


(1) Construct a WeightedData object using whiteWinLoss as weights

wd = WeightedData[ratingdiff, whiteWinLoss];


(2) Use Histogram with bin width 10 and height spec "Probability":

Histogram[wd, {10}, "Probability"]