当前位置: 首页>>代码示例>>Java>>正文


Java Frequency类代码示例

本文整理汇总了Java中org.apache.commons.math3.stat.Frequency的典型用法代码示例。如果您正苦于以下问题:Java Frequency类的具体用法?Java Frequency怎么用?Java Frequency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Frequency类属于org.apache.commons.math3.stat包,在下文中一共展示了Frequency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkNextIntUniform

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
private void checkNextIntUniform(int min, int max) {
    final Frequency freq = new Frequency();
    for (int i = 0; i < smallSampleSize; i++) {
        final int value = randomData.nextInt(min, max);
        Assert.assertTrue("nextInt range", (value >= min) && (value <= max));
        freq.addValue(value);
    }
    final int len = max - min + 1;
    final long[] observed = new long[len];
    for (int i = 0; i < len; i++) {
        observed[i] = freq.getCount(min + i);
    }
    final double[] expected = new double[len];
    for (int i = 0; i < len; i++) {
        expected[i] = 1d / len;
    }
    
    TestUtils.assertChiSquareAccept(expected, observed, 0.001);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:RandomDataGeneratorTest.java

示例2: checkNextLongUniform

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
private void checkNextLongUniform(long min, long max) {
    final Frequency freq = new Frequency();
    for (int i = 0; i < smallSampleSize; i++) {
        final long value = randomData.nextLong(min, max);
        Assert.assertTrue("nextLong range: " + value + " " + min + " " + max,
                          (value >= min) && (value <= max));
        freq.addValue(value);
    }
    final int len = ((int) (max - min)) + 1;
    final long[] observed = new long[len];
    for (int i = 0; i < len; i++) {
        observed[i] = freq.getCount(min + i);
    }
    final double[] expected = new double[len];
    for (int i = 0; i < len; i++) {
        expected[i] = 1d / len;
    }
    
    TestUtils.assertChiSquareAccept(expected, observed, 0.01);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:21,代码来源:RandomDataGeneratorTest.java

示例3: checkNextSecureLongUniform

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
private void checkNextSecureLongUniform(int min, int max) {
    final Frequency freq = new Frequency();
    for (int i = 0; i < smallSampleSize; i++) {
        final long value = randomData.nextSecureLong(min, max);
        Assert.assertTrue("nextLong range", (value >= min) && (value <= max));
        freq.addValue(value);
    }
    final int len = max - min + 1;
    final long[] observed = new long[len];
    for (int i = 0; i < len; i++) {
        observed[i] = freq.getCount(min + i);
    }
    final double[] expected = new double[len];
    for (int i = 0; i < len; i++) {
        expected[i] = 1d / len;
    }
    
    TestUtils.assertChiSquareAccept(expected, observed, 0.0001);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:RandomDataGeneratorTest.java

示例4: checkNextSecureIntUniform

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
private void checkNextSecureIntUniform(int min, int max) {
    final Frequency freq = new Frequency();
    for (int i = 0; i < smallSampleSize; i++) {
        final int value = randomData.nextSecureInt(min, max);
        Assert.assertTrue("nextInt range", (value >= min) && (value <= max));
        freq.addValue(value);
    }
    final int len = max - min + 1;
    final long[] observed = new long[len];
    for (int i = 0; i < len; i++) {
        observed[i] = freq.getCount(min + i);
    }
    final double[] expected = new double[len];
    for (int i = 0; i < len; i++) {
        expected[i] = 1d / len;
    }
    
    TestUtils.assertChiSquareAccept(expected, observed, 0.0001);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:RandomDataGeneratorTest.java

示例5: doBins

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public static BinnedData doBins(IDocument<?> collection)
{

  // build up the histogram
  Frequency freq = new Frequency();
  Iterator<?> iter2 = collection.getIterator();
  while (iter2.hasNext())
  {
    Object object = (Object) iter2.next();
    freq.addValue(object.toString());
  }

  BinnedData res = new BinnedData();

  Iterator<Comparable<?>> vIter = freq.valuesIterator();
  while (vIter.hasNext())
  {
    Comparable<?> value = vIter.next();
    res.add(new Bin(value, freq.getCount(value)));
  }

  return res;
}
 
开发者ID:debrief,项目名称:limpet,代码行数:24,代码来源:ObjectFrequencyBins.java

示例6: checkNextLongUniform

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
private void checkNextLongUniform(int min, int max) {
    final Frequency freq = new Frequency();
    for (int i = 0; i < smallSampleSize; i++) {
        final long value = randomData.nextLong(min, max);
        Assert.assertTrue("nextLong range", (value >= min) && (value <= max));
        freq.addValue(value);
    }
    final int len = max - min + 1;
    final long[] observed = new long[len];
    for (int i = 0; i < len; i++) {
        observed[i] = freq.getCount(min + i);
    }
    final double[] expected = new double[len];
    for (int i = 0; i < len; i++) {
        expected[i] = 1d / len;
    }
    
    TestUtils.assertChiSquareAccept(expected, observed, 0.01);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:RandomDataTest.java

示例7: getCDF

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public static void getCDF(int rangeI, int rangeF, int increment) {
	long startTime = -1;
	valuesFreq = new Frequency();
	Scanner scanner = new Scanner(System.in);
	while (scanner.hasNext()) {
		if (scanner.hasNextLong()) {
			long opStartTime = scanner.nextLong();
			long opTime = scanner.nextLong();
			if (startTime == -1) {
				startTime = opStartTime;
			}
			if (opStartTime - startTime > WARMUP_TIME)
				valuesFreq.addValue(opTime);
		} else
			scanner.nextLine();
	}
	scanner.close();

	System.out.printf("LAT\tCUM_FREQ\n");
	for (int i = rangeI; i <= rangeF; i += increment) {
		System.out.printf("%d\t%f\n", i, valuesFreq.getCumPct(i));
	}

}
 
开发者ID:SyncFree,项目名称:Indigo,代码行数:25,代码来源:StatisticsUtils.java

示例8: getFreqStats

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public void getFreqStats(double[] values){
	Frequency freq = new Frequency();
	for( int i = 0; i < values.length; i++) {
		freq.addValue(values[i]);
	}

	for( int i = 0; i < values.length; i++) {
		System.out.println(freq.getCount(values[i]));
	}
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:11,代码来源:FrequencyStats.java

示例9: getFreqStats

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public void getFreqStats(String[] words){
	Frequency freq = new Frequency();
	for( int i = 0; i < words.length; i++) {
		freq.addValue(words[i].trim());
	}

	for( int i = 0; i < words.length; i++) {
		System.out.println(words[i] + "=" + freq.getCount(words[i]));
	}
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:11,代码来源:WordFrequencyStatsApache.java

示例10: formatFrequency

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public static String formatFrequency(Frequency frequency, int maxCount) {
	List<Map.Entry<Comparable<?>, Long>> list = sortByFrequency(frequency);
	String result = "";
	
	for (int i = 0; i < maxCount && i < list.size(); i++) {
		String percent = String.format(Locale.US, "%.0f",
				frequency.getPct(list.get(i).getKey()) * 100) + "%";
		
		result += list.get(i).getKey() + ","
				+ list.get(i).getValue() + ","
				+ percent + "\n";
	}		
	
	return result;		
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:16,代码来源:FrequencyUtils.java

示例11: sortByFrequency

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public static List<Map.Entry<Comparable<?>, Long>> sortByFrequency(Frequency frequency) {
	Iterator<Map.Entry<Comparable<?>, Long>>  iterator =  frequency.entrySetIterator();
	
	List<Map.Entry<Comparable<?>, Long>> list = new ArrayList<Map.Entry<Comparable<?>, Long>>();
	
	while (iterator.hasNext()) {
		Map.Entry<Comparable<?>, Long> entry = iterator.next();
		
		list.add(entry);
	}
	
	Comparator<Map.Entry<Comparable<?>, Long>> comparator =
			new Comparator<Map.Entry<Comparable<?>, Long>>() {

		@Override
		public int compare(Map.Entry<Comparable<?>, Long> arg0,
				Map.Entry<Comparable<?>, Long> arg1) {
			if (arg0 == null || arg1 == null) {
				throw new NullPointerException();
			}					
			
			return -Long.compare(arg0.getValue(), arg1.getValue());
		}			
	};
	
	Collections.sort(list, comparator);
	
	return list;
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:30,代码来源:FrequencyUtils.java

示例12: formatTopItems

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public String formatTopItems(Frequency frequency, int maxCount) {
		itemStore.flushItems();
		
		List<Map.Entry<Comparable<?>, Long>> list = FrequencyUtils.sortByFrequency(frequency);
		String result = "";
		
		for (int i = 0; i < maxCount && i < list.size(); i++) {
//			String percent = String.format(Locale.US, "%.0f", frequency.getPct(list.get(i).getKey()) * 100) + "%";
			
			int itemId = (int) (long) ((Long) list.get(i).getKey());
			int count = (int) (long) ((Long) list.get(i).getValue());
			String label = null;
			Integer instanceOfId = null;
			String instanceOfLabel = null;

			DbItem item = itemStore.getItem(itemId);
			
			if (item != null) {
				label = item.getLabel();
				instanceOfId = item.getInstanceOfId();
				if (instanceOfId != null) {
					DbItem instanceOfItem = itemStore.getItem(instanceOfId);
					if (instanceOfItem != null) {
						instanceOfLabel = instanceOfItem.getLabel();
					}
				}
			}
			
			result += itemId + "," + count + "," + label + "," + instanceOfId + "," + instanceOfLabel + "\n";
		}		
		
		return result;
	}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:34,代码来源:CorpusStatisticsProcessor.java

示例13: frequency

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public ReflexValue frequency(List<ReflexValue> params) {
    if (params.size() != 1) {
        throw new ReflexException(-1, "frequency needs one list parameter");
    }
    if (!params.get(0).isList()) {
        throw new ReflexException(-1, "frequency needs one list parameter");
    }
    Frequency f = new Frequency();
    List<ReflexValue> values = params.get(0).asList();
    for (ReflexValue v : values) {
        f.addValue(v.asDouble());
    }
    return new ReflexValue(f);
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:15,代码来源:ReflexStatistics.java

示例14: frequency_count

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public ReflexValue frequency_count(List<ReflexValue> params) {
    if (params.size() != 2) {
        throw new ReflexException(-1, "frequency_count needs one frequency parameter and one value parameter");
    }
    Frequency f = params.get(0).asObjectOfType(Frequency.class);
    double value = params.get(1).asDouble();
    return new ReflexValue(f.getCount(value));
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:9,代码来源:ReflexStatistics.java

示例15: frequency_cum_pct

import org.apache.commons.math3.stat.Frequency; //导入依赖的package包/类
public ReflexValue frequency_cum_pct(List<ReflexValue> params) {
    if (params.size() != 2) {
        throw new ReflexException(-1, "frequency_count needs one frequency parameter and one value parameter");
    }
    Frequency f = params.get(0).asObjectOfType(Frequency.class);
    double value = params.get(1).asDouble();
    return new ReflexValue(f.getCumPct(value));
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:9,代码来源:ReflexStatistics.java


注:本文中的org.apache.commons.math3.stat.Frequency类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。