@Test public void testFrequencies() { logger.info("frequencies"); FlatDataCollection flatDataCollection = new FlatDataCollection(Arrays.asList(new Object[]{1.0,1.0,1.0,2.0,3.0,4.3,2.0})); AssociativeArray expResult = new AssociativeArray(); expResult.put(1.0, 3); expResult.put(2.0, 2); expResult.put(3.0, 1); expResult.put(4.3, 1); AssociativeArray result = Descriptives.frequencies(flatDataCollection); assertEquals(expResult, result); }
public static AssociativeArray frequencies(FlatDataCollection flatDataCollection) { AssociativeArray frequencies = new AssociativeArray(); for (Object value : flatDataCollection) { Object counter = frequencies.get(value); if(counter==null) { frequencies.put(value, 1); } else { frequencies.put(value, ((Number)counter).intValue()+1); } } return frequencies; }
Descriptives { public static AssociativeArray frequencies(FlatDataCollection flatDataCollection) { AssociativeArray frequencies = new AssociativeArray(); for (Object value : flatDataCollection) { Object counter = frequencies.get(value); if(counter==null) { frequencies.put(value, 1); } else { frequencies.put(value, ((Number)counter).intValue()+1); } } return frequencies; } }
Descriptives { public static AssociativeArray frequencies(FlatDataCollection flatDataCollection) { AssociativeArray frequencies = new AssociativeArray(); for (Object value : flatDataCollection) { Object counter = frequencies.get(value); if(counter==null) { frequencies.put(value, 1); } else { frequencies.put(value, ((Number)counter).intValue()+1); } } return frequencies; }  }
Descriptives { public static AssociativeArray frequencies(FlatDataCollection flatDataCollection) { AssociativeArray frequencies = new AssociativeArray(); for (Object value : flatDataCollection) { Object counter = frequencies.get(value); if(counter==null) { frequencies.put(value, 1); } else { frequencies.put(value, ((Number)counter).intValue()+1); } } return frequencies; }  static int count(Iterable it); static double sum(FlatDataCollection flatDataCollection); static double mean(FlatDataCollection flatDataCollection); static double meanSE(FlatDataCollection flatDataCollection); static double median(FlatDataCollection flatDataCollection); static double min(FlatDataCollection flatDataCollection); static double max(FlatDataCollection flatDataCollection); static double minAbsolute(FlatDataCollection flatDataCollection); static double maxAbsolute(FlatDataCollection flatDataCollection); static double range(FlatDataCollection flatDataCollection); static double geometricMean(FlatDataCollection flatDataCollection); static double harmonicMean(FlatDataCollection flatDataCollection); static double variance(FlatDataCollection flatDataCollection, boolean isSample); static double std(FlatDataCollection flatDataCollection, boolean isSample); static double cv(double std, double mean); static double moment(FlatDataCollection flatDataCollection, int r); static double moment(FlatDataCollection flatDataCollection, int r, double mean); static double kurtosis(FlatDataCollection flatDataCollection); static double kurtosisSE(FlatDataCollection flatDataCollection); static double skewness(FlatDataCollection flatDataCollection); static double skewnessSE(FlatDataCollection flatDataCollection); static AssociativeArray percentiles(FlatDataCollection flatDataCollection, int cutPoints); static AssociativeArray quartiles(FlatDataCollection flatDataCollection); static double covariance(TransposeDataList transposeDataList, boolean isSample); static double autocorrelation(FlatDataList flatDataList, int lags); static AssociativeArray frequencies(FlatDataCollection flatDataCollection); static FlatDataCollection mode(FlatDataCollection flatDataCollection); static void normalize(AssociativeArray associativeArray); static void normalizeExp(AssociativeArray associativeArray); }
Descriptives { public static AssociativeArray frequencies(FlatDataCollection flatDataCollection) { AssociativeArray frequencies = new AssociativeArray(); for (Object value : flatDataCollection) { Object counter = frequencies.get(value); if(counter==null) { frequencies.put(value, 1); } else { frequencies.put(value, ((Number)counter).intValue()+1); } } return frequencies; }  static int count(Iterable it); static double sum(FlatDataCollection flatDataCollection); static double mean(FlatDataCollection flatDataCollection); static double meanSE(FlatDataCollection flatDataCollection); static double median(FlatDataCollection flatDataCollection); static double min(FlatDataCollection flatDataCollection); static double max(FlatDataCollection flatDataCollection); static double minAbsolute(FlatDataCollection flatDataCollection); static double maxAbsolute(FlatDataCollection flatDataCollection); static double range(FlatDataCollection flatDataCollection); static double geometricMean(FlatDataCollection flatDataCollection); static double harmonicMean(FlatDataCollection flatDataCollection); static double variance(FlatDataCollection flatDataCollection, boolean isSample); static double std(FlatDataCollection flatDataCollection, boolean isSample); static double cv(double std, double mean); static double moment(FlatDataCollection flatDataCollection, int r); static double moment(FlatDataCollection flatDataCollection, int r, double mean); static double kurtosis(FlatDataCollection flatDataCollection); static double kurtosisSE(FlatDataCollection flatDataCollection); static double skewness(FlatDataCollection flatDataCollection); static double skewnessSE(FlatDataCollection flatDataCollection); static AssociativeArray percentiles(FlatDataCollection flatDataCollection, int cutPoints); static AssociativeArray quartiles(FlatDataCollection flatDataCollection); static double covariance(TransposeDataList transposeDataList, boolean isSample); static double autocorrelation(FlatDataList flatDataList, int lags); static AssociativeArray frequencies(FlatDataCollection flatDataCollection); static FlatDataCollection mode(FlatDataCollection flatDataCollection); static void normalize(AssociativeArray associativeArray); static void normalizeExp(AssociativeArray associativeArray);  }