本文整理汇总了Java中org.apache.commons.math.stat.Frequency.addValue方法的典型用法代码示例。如果您正苦于以下问题:Java Frequency.addValue方法的具体用法?Java Frequency.addValue怎么用?Java Frequency.addValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.stat.Frequency
的用法示例。
在下文中一共展示了Frequency.addValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNextInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextInt() */
public void testNextInt() {
try {
randomData.nextInt(4,3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
Frequency freq = new Frequency();
int value = 0;
for (int i=0;i<smallSampleSize;i++) {
value = randomData.nextInt(0,3);
assertTrue("nextInt range",(value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例2: testNextLong
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextLong() */
public void testNextLong() {
try {
randomData.nextLong(4,3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
Frequency freq = new Frequency();
long value = 0;
for (int i=0;i<smallSampleSize;i++) {
value = randomData.nextLong(0,3);
assertTrue("nextInt range",(value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例3: testNextSecureLong
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureLong() */
public void testNextSecureLong() {
try {
randomData.nextSecureLong(4,3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
Frequency freq = new Frequency();
long value = 0;
for (int i=0;i<smallSampleSize;i++) {
value = randomData.nextSecureLong(0,3);
assertTrue("nextInt range",(value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例4: testNextSecureInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureInt() */
public void testNextSecureInt() {
try {
randomData.nextSecureInt(4,3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
Frequency freq = new Frequency();
int value = 0;
for (int i=0;i<smallSampleSize;i++) {
value = randomData.nextSecureInt(0,3);
assertTrue("nextInt range",(value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例5: testNextInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public void testNextInt() {
try {
testGenerator.nextInt(-1);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
Frequency freq = new Frequency();
int value = 0;
for (int i=0; i<smallSampleSize; i++) {
value = testGenerator.nextInt(4);
assertTrue("nextInt range",(value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例6: testNextInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
@Override
public void testNextInt() {
try {
testGenerator.nextInt(-1);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// ignored
}
Frequency freq = new Frequency();
int value = 0;
for (int i=0; i<smallSampleSize; i++) {
value = testGenerator.nextInt(4);
assertTrue("nextInt range",(value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例7: export
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
private static void export(File argumentsWithReasonsFile, File argumentsWithGistFile,
File outputDir)
throws Exception
{
List<StandaloneArgument> arguments = ExportHelper.copyReasonAnnotationsWithGistOnly(
argumentsWithReasonsFile, argumentsWithGistFile);
String metaDataCSV = ExportHelper.exportMetaDataToCSV(arguments);
FileUtils.write(new File(outputDir, "metadata.csv"), metaDataCSV, "utf-8");
Frequency premisesFrequency = new Frequency();
DescriptiveStatistics premisesStatistics = new DescriptiveStatistics();
// and export them all as XMI files using standard DKPro pipeline
for (StandaloneArgument argument : arguments) {
JCas jCas = argument.getJCas();
SimplePipeline.runPipeline(jCas, AnalysisEngineFactory.createEngineDescription(
XmiWriter.class,
XmiWriter.PARAM_TARGET_LOCATION, outputDir,
XmiWriter.PARAM_USE_DOCUMENT_ID, true,
XmiWriter.PARAM_OVERWRITE, true
));
// count all premises
int count = JCasUtil.select(jCas, Premise.class).size();
premisesStatistics.addValue(count);
premisesFrequency.addValue(count);
}
System.out.println("Premises total: " + premisesStatistics.getSum());
System.out.println("Argument: " + arguments.size());
System.out.println(premisesFrequency);
}
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:34,代码来源:Step3dExportGistToXMIFiles.java
示例8: computeStatistics
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
private static void computeStatistics(List<StandaloneArgument> annotatedArguments,
int skippedArgumentsFromMACE)
{
Frequency frequency = new Frequency();
for (int i = 0; i < skippedArgumentsFromMACE; i++) {
frequency.addValue("Skipped from MACE");
}
for (StandaloneArgument argument : annotatedArguments) {
String annotatedStance = argument.getAnnotatedStance();
if (annotatedStance != null) {
int intValue = argument.getMappingAllStancesToInt().get(annotatedStance);
// 0 and 1 treat as one stance (pro/con doesn't matter here)
if (intValue == 1) {
intValue = 0;
}
frequency.addValue(String.valueOf(intValue) + (argument.isAnnotatedSarcastic() ?
"_sarc" :
""));
}
else {
frequency.addValue("No stance");
}
}
System.out.println(frequency);
}
示例9: main
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public static void main(String[] args)
throws IOException
{
File inputFile = new File(
"mturk/annotation-task/data/32-reasons-batch-0001-5000-2026args-gold.xml.gz");
// read all arguments from the original corpus
List<StandaloneArgument> arguments = XStreamSerializer
.deserializeArgumentListFromXML(inputFile);
System.out.println("Arguments: " + arguments.size());
Frequency frequency = new Frequency();
DescriptiveStatistics statistics = new DescriptiveStatistics();
for (StandaloneArgument argument : arguments) {
JCas jCas = argument.getJCas();
Collection<Premise> premises = JCasUtil.select(jCas, Premise.class);
frequency.addValue(premises.size());
statistics.addValue(premises.size());
}
System.out.println(frequency);
System.out.println(statistics.getSum());
System.out.println(statistics.getMean());
System.out.println(statistics.getStandardDeviation());
}
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:28,代码来源:Step2dGoldReasonStatistics.java
示例10: testNextLong
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public void testNextLong() {
long q1 = Long.MAX_VALUE/4;
long q2 = 2 * q1;
long q3 = 3 * q1;
Frequency freq = new Frequency();
long val = 0;
int value = 0;
for (int i=0; i<smallSampleSize; i++) {
val = testGenerator.nextLong();
if (val < q1) {
value = 0;
} else if (val < q2) {
value = 1;
} else if (val < q3) {
value = 2;
} else {
value = 3;
}
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例11: testNextFloat
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public void testNextFloat() {
Frequency freq = new Frequency();
float val = 0;
int value = 0;
for (int i=0; i<smallSampleSize; i++) {
val = testGenerator.nextFloat();
if (val < 0.25) {
value = 0;
} else if (val < 0.5) {
value = 1;
} else if (val < 0.75) {
value = 2;
} else {
value = 3;
}
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例12: testNextSecureInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureInt() */
public void testNextSecureInt() {
try {
randomData.nextSecureInt(4, 3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// ignored
}
Frequency freq = new Frequency();
int value = 0;
for (int i = 0; i < smallSampleSize; i++) {
value = randomData.nextSecureInt(0, 3);
assertTrue("nextInt range", (value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i = 0; i < 4; i++) {
observed[i] = freq.getCount(i);
}
/*
* Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
* for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected, observed) < 16.27);
}
示例13: testNextLong
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextLong() */
public void testNextLong() {
try {
randomData.nextLong(4, 3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// ignored
}
Frequency freq = new Frequency();
long value = 0;
for (int i = 0; i < smallSampleSize; i++) {
value = randomData.nextLong(0, 3);
assertTrue("nextInt range", (value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i = 0; i < 4; i++) {
observed[i] = freq.getCount(i);
}
/*
* Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
* for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected, observed) < 16.27);
}
示例14: testNextGuassionInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
@Test
public void testNextGuassionInt() throws Exception {
int low = 0;
int high = 4;
int total = 10000;
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
Frequency freq = new Frequency();
for ( int i=0; i<total; i++ ) {
int result = MathUtil.nextGaussionInt(low, high, 4.0);
freq.addValue(result);
Integer countInt = (Integer)map.get(result);
int count = 1;
if ( countInt != null ) {
count = countInt.intValue();
}
map.put(result, count+1);
}
for ( Integer key : map.keySet() ) {
System.out.println(key+":"+map.get(key)*1.0d/total);
}
for ( int i=low; i<high; i++ ) {
System.out.print("i="+i);
System.out.print(", count: "+freq.getCount(i));
System.out.print(", comfreq: "+freq.getCumFreq(i));
System.out.print(", comPct: "+freq.getCumPct(i));
System.out.print(", pct: "+freq.getPct(i));
System.out.println();
}
}
示例15: testNextSecureInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureInt() */
public void testNextSecureInt() {
try {
randomData.nextSecureInt(4, 3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// ignored
}
Frequency freq = new Frequency();
int value = 0;
for (int i = 0; i < smallSampleSize; i++) {
value = randomData.nextSecureInt(0, 3);
assertTrue("nextInt range", (value >= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i = 0; i < 4; i++) {
observed[i] = freq.getCount(i);
}
/*
* Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
* for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected, observed) < 16.27);
}