It is assumed that var is sorted in ascending order */
| 184 | |
| 185 | /** It is assumed that var is sorted in ascending order */ |
| 186 | void CatClassification::SetBreakPoints(std::vector<double>& breaks, |
| 187 | std::vector<wxString>& cat_labels, |
| 188 | const Gda::dbl_int_pair_vec_type& var, |
| 189 | const std::vector<bool>& var_undef, |
| 190 | const CatClassifType theme, |
| 191 | int num_cats, |
| 192 | bool useScientificNotation, |
| 193 | int cat_disp_precision) |
| 194 | { |
| 195 | int num_obs = var.size(); |
| 196 | if (num_cats < 1) num_cats = 1; |
| 197 | if (num_cats > 10) num_cats = 10; |
| 198 | |
| 199 | breaks.resize(num_cats-1); |
| 200 | cat_labels.resize(num_cats); |
| 201 | |
| 202 | if (theme == CatClassification::percentile || |
| 203 | theme == CatClassification::hinge_15 || |
| 204 | theme == CatClassification::hinge_30 || |
| 205 | theme == CatClassification::stddev || |
| 206 | theme == CatClassification::excess_risk_theme) { |
| 207 | num_cats = 6; |
| 208 | } else if (theme == no_theme) { |
| 209 | num_cats = 1; |
| 210 | cat_labels[0] = ""; |
| 211 | } |
| 212 | |
| 213 | // no_theme handled by default |
| 214 | if (theme == hinge_15 || theme == hinge_30) { |
| 215 | HingeStats hinge_stats; |
| 216 | hinge_stats.CalculateHingeStats(var); |
| 217 | breaks[0] = (theme == hinge_15 ? hinge_stats.extreme_lower_val_15 : |
| 218 | hinge_stats.extreme_lower_val_30); |
| 219 | breaks[1] = hinge_stats.Q1; |
| 220 | breaks[2] = hinge_stats.Q2; |
| 221 | breaks[3] = hinge_stats.Q3; |
| 222 | breaks[4] = (theme == hinge_15 ? hinge_stats.extreme_upper_val_15 : |
| 223 | hinge_stats.extreme_upper_val_30); |
| 224 | cat_labels[0] = _("Lower outlier"); |
| 225 | cat_labels[1] = "< 25%"; |
| 226 | cat_labels[2] = "25% - 50%"; |
| 227 | cat_labels[3] = "50% - 75%"; |
| 228 | cat_labels[4] = "> 75%"; |
| 229 | cat_labels[5] = _("Upper outlier"); |
| 230 | |
| 231 | } else if (theme == quantile) { |
| 232 | if (num_cats == 1) { |
| 233 | // already handled |
| 234 | } else { |
| 235 | for (int i=0, iend=breaks.size(); i<iend; i++) { |
| 236 | breaks[i] = |
| 237 | Gda::percentile(((i+1.0)*100.0)/((double) num_cats), var); |
| 238 | } |
| 239 | } |
| 240 | CatLabelsFromBreaks(breaks, cat_labels, theme, useScientificNotation, |
| 241 | cat_disp_precision); |
| 242 | |
| 243 | } else if (theme == percentile) { |
nothing calls this directly
no test coverage detected