Cody

# Problem 46657. Grouped Frequency Distributions

Solution 3730868

Submitted on 19 Nov 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
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; y_correct = [2,12,8;12,22,10;22,32,5;32,42,4]; assert(isequal(groupedFreq(dataset,numClass),y_correct))

R = 2 6 10 14 18 22 26 30 34 38

Error using matlab.internal.math.parsegroupbins (line 87) Invalid binning scheme. Error in groupcounts (line 127) [groupBins,scalarExpandBins] = matlab.internal.math.parsegroupbins(varargin{indStart},numel(gvLabels),'groupcounts'); Error in groupedFreq (line 3) groupcounts(dataset,[],R) Error in Test1 (line 6) assert(isequal(groupedFreq(dataset,numClass),y_correct))

2   Fail
dataset = [-52;5;2;-68;-74;-20;45;-43;-8;-59;15;-55;-19;8;35;45;-13;-71;-69;-54;28;-55;24;-56;41;-41;-63;-55;-4;-24;-41;27;-8;-13;39;-50;16;16;-37;-10;-80;-83;-16;19;41;-72;-10;-24;-89;-43]; numClass = 5; y_correct = [-89,-62,9;-62,-35,13;-35,-8,9;-8,19,9;19,46,10]; assert(isequal(groupedFreq(dataset,numClass),y_correct))

R = -89 -84 -79 -74 -69 -64 -59 -54 -49 -44 -39 -34 -29 -24 -19 -14 -9 -4 1 6 11 16 21 26 31 36 41

Error using matlab.internal.math.parsegroupbins (line 87) Invalid binning scheme. Error in groupcounts (line 127) [groupBins,scalarExpandBins] = matlab.internal.math.parsegroupbins(varargin{indStart},numel(gvLabels),'groupcounts'); Error in groupedFreq (line 3) groupcounts(dataset,[],R) Error in Test2 (line 4) assert(isequal(groupedFreq(dataset,numClass),y_correct))

3   Fail
dataset = [138,0,69,64,69,116,48,118,71,5,26,108,71,23,51,91,28,111,36,138,40,115,28,43,13,87,103,82,64,97,97,102,96,142,31,107,35,18,91,67,69,99,116,52,99,62,127,125,38,92,87,81,131,39,48,18,141,97,72,96,82,97,82,108,78,150,33,15,16,9,61,67,55,115,94,116,140,146,28,20,105,14,79,80,130,73,59,101,111,78,52,22,88,39,6,113,36,66,103,54,111,59,103,106,66,2,49,64,40,29,124,64,134,59,116,59,122,114,56,32,119,143,49,101,66,125,116,25,130,149,77,133,88,23,30,61,113,124,119,48,80,13,16,20,102,74,28,74,22,8]; numClass = 4; y_correct = [0,38,34;38,76,42;76,114,43;114,152,31]; assert(isequal(groupedFreq(dataset,numClass),y_correct))

R = Columns 1 through 29 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 Columns 30 through 38 116 120 124 128 132 136 140 144 148

Error using matlab.internal.math.parsegroupbins (line 87) Invalid binning scheme. Error in groupcounts (line 127) [groupBins,scalarExpandBins] = matlab.internal.math.parsegroupbins(varargin{indStart},numel(gvLabels),'groupcounts'); Error in groupedFreq (line 3) groupcounts(dataset,[],R) Error in Test3 (line 4) assert(isequal(groupedFreq(dataset,numClass),y_correct))

4   Fail
dataset = [-56;45;26;126;3;9;-74;-91;45;0;60;-51;173;30;104;2;7;75;64;-70;-103;-68;-93;25;-13;-9;-89;82;55;13;102;-50;53;48;48;-38;46;-21;-52;-76;103;-48;6;-77;-4;-239;-67;-94] numClass = 5; y_correct = [-239,-156,1;-156,-73,8;-73,10,19;10,93,15;93,176,5]; assert(isequal(groupedFreq(dataset,numClass),y_correct))

dataset = -56 45 26 126 3 9 -74 -91 45 0 60 -51 173 30 104 2 7 75 64 -70 -103 -68 -93 25 -13 -9 -89 82 55 13 102 -50 53 48 48 -38 46 -21 -52 -76 103 -48 6 -77 -4 -239 -67 -94 R = Columns 1 through 29 -239 -234 -229 -224 -219 -214 -209 -204 -199 -194 -189 -184 -179 -174 -169 -164 -159 -154 -149 -144 -139 -134 -129 -124 -119 -114 -109 -104 -99 Columns 30 through 58 -94 -89 -84 -79 -74 -69 -64 -59 -54 -49 -44 -39 -34 -29 -24 -19 -14 -9 -4 1 6 11 16 21 26 31 36 41 46 Columns 59 through 83 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 126 131 136 141 146 151 156 161 166 171

Error using matlab.internal.math.parsegroupbins (line 87) Invalid binning scheme. Error in groupcounts (line 127) [groupBins,scalarExpandBins] = matlab.internal.math.parsegroupbins(varargin{indStart},numel(gvLabels),'groupcounts'); Error in groupedFreq (line 3) groupcounts(dataset,[],R) Error in Test4 (line 4) assert(isequal(groupedFreq(dataset,numClass),y_correct))

5   Fail
dataset = [383;129;199;139;119;128;105;23;179;241;47;293;82;76;10;21;5;135;260;153;185;234;387;83;135;172;-30;-1;179;88;155;4;-63;176;219;263;-53;-34;-47;96;38;231;-46;-74;121;219;20;-27;85;-64;102;183;122;390;46;70;281;191;94;231;-4;65;241;250;173;149;41;174;17;157;128;214;57;164;179;10;116;260;111;69;146;72;144;87;98]; numClass = 5; y_correct =[-74,19,16;19,112,24;112,205,28;205,298,14;298,391,3]; assert(isequal(groupedFreq(dataset,numClass),y_correct))

R = Columns 1 through 29 -74 -69 -64 -59 -54 -49 -44 -39 -34 -29 -24 -19 -14 -9 -4 1 6 11 16 21 26 31 36 41 46 51 56 61 66 Columns 30 through 58 71 76 81 86 91 96 101 106 111 116 121 126 131 136 141 146 151 156 161 166 171 176 181 186 191 196 201 206 211 Columns 59 through 87 216 221 226 231 236 241 246 251 256 261 266 271 276 281 286 291 296 301 306 311 316 321 326 331 336 341 346 351 356 Columns 88 through 93 361 366 371 376 381 386

Error using matlab.internal.math.parsegroupbins (line 87) Invalid binning scheme. Error in groupcounts (line 127) [groupBins,scalarExpandBins] = matlab.internal.math.parsegroupbins(varargin{indStart},numel(gvLabels),'groupcounts'); Error in groupedFreq (line 3) groupcounts(dataset,[],R) Error in Test5 (line 4) assert(isequal(groupedFreq(dataset,numClass),y_correct))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!