You will write three small functions that turn a list of values into the numbers behind a histogram: the counts in each bin, the relative frequencies and the frequency densities.
The idea. A bin from left to left + width holds a value x when left <= x < left + width, so an edge value goes into the bin above. A relative frequency is a count divided by the total. A frequency density is a count divided by the width.
Your tasks.
bin_counts(data, start, width, n_bins). Return a list of n_bins counts.relative(counts). Return each count divided by the sum of the counts.density(counts, widths). Return each count divided by the width of its bin.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…