本文整理汇总了Java中org.apache.commons.math.stat.Frequency.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java Frequency.getCount方法的具体用法?Java Frequency.getCount怎么用?Java Frequency.getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.stat.Frequency
的用法示例。
在下文中一共展示了Frequency.getCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: frequencyToStatistics
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
public static DescriptiveStatistics frequencyToStatistics(Frequency frequency)
{
Iterator<Comparable<?>> comparableIterator = frequency.valuesIterator();
DescriptiveStatistics result = new DescriptiveStatistics();
while (comparableIterator.hasNext()) {
Comparable<?> next = comparableIterator.next();
long count = frequency.getCount(next);
for (int i = 0; i < count; i++) {
if (next instanceof Number) {
result.addValue(((Number) next).doubleValue());
}
}
}
return result;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: testNextInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextInt() */
public void testNextInt() {
try {
int x = 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);
}
示例9: testNextSecureInt
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextSecureInt() */
public void testNextSecureInt() {
try {
long x = 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);
}
示例10: testNextLong
import org.apache.commons.math.stat.Frequency; //导入方法依赖的package包/类
/** test dispersion and failure modes for nextLong() */
public void testNextLong() {
try {
long x = 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);
}
示例11: 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);
}
示例12: 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);
}
示例13: 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) {
// ignored
}
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);
}
示例14: 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) {
// ignored
}
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);
}
示例15: 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);
}