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
Solution Comments
Show comments
Loading...
Problem Recent Solvers10
Suggested Problems
-
46735 Solvers
-
523 Solvers
-
Side of an equilateral triangle
6883 Solvers
-
552 Solvers
-
Change the first and last diagonal element of the identity matrix to zero
160 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!
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.
I have fixed the error