Problem 46657. Grouped Frequency Distributions
One input is a dataset. The other input is the number of groups (classes). Create grouped frequency distribution by following steps:
dataset = [20,25,35,40,20,14,16,15,14,16,13,10,23,28,29,30,34,32,14,17,11,10,7,5,2,7,7];
numClass = 4;
- Find the range: max - min. range = 40 - 2 = 38
- Find the group (class) width by dividing the range by the number of groups. Round up if the width has decimal point. 38/4 = 9.5. round up. width = 10
- Start with the minimum value of the dataset and add class width.
2 12
12 22
22 32
32 42
- Count the number of occurrences in each group. For the first class you will count occurences greater than or equal to 2 and less than 12. For the second class you will count occurences greater than or equal to 12 and less than 22 and so on.
groups frequency
2 12 8
12 22 10
22 32 5
32 42 4
Solution Stats
Problem Comments
-
2 Comments
William
on 5 Oct 2020
There is an error in the test suite. The solutions act as though the value of numClass is always 4 when setting the bin width, but then use the correct value of numClass when doing the histogram.
Mehmet OZC
on 6 Oct 2020
I have fixed the error
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
Make a random, non-repeating vector.
9272 Solvers
-
706 Solvers
-
Set the array elements whose value is 13 to 0
1369 Solvers
-
743 Solvers
-
205 Solvers
More from this Author92
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!