In the the last lesson we began work on constructing a histogram of the numbers
in the data set. We put forth the idea of bins for the numbers, and computed the boundaries of each bin.
In this lesson, let's loop through all 2,000 data points and place each in its proper bin. What this actually means is for each data point, we'll see what bin it would fall into. And for each bin, we'll keep a tally/counter tracking how many times a number from the data set fell into a given bin.
This is handled in part 4 of the code below. Here, we have i looping through the data points one-by-one. And for each data[i], we'll examine each bin and see if the data point is between the low and high boundart of a bin. If so, we'll increase the count of that bin by one (as one more data point has fallen into that bin).
Now you try. Choose some number of bins and see how the counts in each bin comes out.
Type your code here:
See your results here:
This code will not run! Finish part 4 and see if you can determine if a given data point has fallen with in a bin, then increase the bin's count by 1.
Part 5 will display the results. What do you see? Does each number in the data set appear equally often any other? (No.) Is one data point dominant over the rest (No.)
Share your code
Show a friend, family member, or teacher what you've done!