Returns summary statistics computed in an online fashion for each numeric variable. This returns all summary statistics, but can be less numerically stable and uses more memory. NaNs / missing values will be ignored in the statistics for each column. @param useWeights true to return th
(boolean useWeights)
| 273 | * @return an array of summary statistics |
| 274 | */ |
| 275 | public OnLineStatistics[] getOnlineColumnStats(boolean useWeights) |
| 276 | { |
| 277 | OnLineStatistics[] stats = new OnLineStatistics[numNumerVals]; |
| 278 | for(int i = 0; i < stats.length; i++) |
| 279 | stats[i] = new OnLineStatistics(); |
| 280 | |
| 281 | double totalSoW = 0.0; |
| 282 | |
| 283 | /** |
| 284 | * We got to skip nans, count their weight in each column so that we can still fast count zeros |
| 285 | */ |
| 286 | double[] nanWeight = new double[numNumerVals]; |
| 287 | |
| 288 | for(Iterator<DataPoint> iter = getDataPointIterator(); iter.hasNext(); ) |
| 289 | { |
| 290 | DataPoint dp = iter.next(); |
| 291 | |
| 292 | double weight = useWeights ? dp.getWeight() : 1; |
| 293 | totalSoW += weight; |
| 294 | |
| 295 | Vec v = dp.getNumericalValues(); |
| 296 | for (IndexValue iv : v) |
| 297 | if (Double.isNaN(iv.getValue()))//count it so we can fast count zeros right later |
| 298 | nanWeight[iv.getIndex()] += weight; |
| 299 | else |
| 300 | stats[iv.getIndex()].add(iv.getValue(), weight); |
| 301 | } |
| 302 | |
| 303 | double expected = totalSoW; |
| 304 | //Add zero counts back in |
| 305 | for(int i = 0; i < stats.length; i++) |
| 306 | stats[i].add(0.0, expected-stats[i].getSumOfWeights()-nanWeight[i]); |
| 307 | |
| 308 | return stats; |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Returns an {@link OnLineStatistics } object that is built by observing |
no test coverage detected