本文整理汇总了Java中org.apache.commons.math3.stat.Frequency.addValue方法的典型用法代码示例。如果您正苦于以下问题:Java Frequency.addValue方法的具体用法?Java Frequency.addValue怎么用?Java Frequency.addValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.stat.Frequency
的用法示例。
在下文中一共展示了Frequency.addValue方法的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例7: 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]));
}
}
示例8: 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]));
}
}
示例9: 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);
}
示例10: checkNextUniformUniform
import org.apache.commons.math3.stat.Frequency; //导入方法依赖的package包/类
private void checkNextUniformUniform(double min, double max) {
// Set up bin bounds - min, binBound[0], ..., binBound[binCount-2], max
final int binCount = 5;
final double binSize = max / binCount - min/binCount; // Prevent overflow in extreme value case
final double[] binBounds = new double[binCount - 1];
binBounds[0] = min + binSize;
for (int i = 1; i < binCount - 1; i++) {
binBounds[i] = binBounds[i - 1] + binSize; // + instead of * to avoid overflow in extreme case
}
final Frequency freq = new Frequency();
for (int i = 0; i < smallSampleSize; i++) {
final double value = randomData.nextUniform(min, max);
Assert.assertTrue("nextUniform range", (value > min) && (value < max));
// Find bin
int j = 0;
while (j < binCount - 1 && value > binBounds[j]) {
j++;
}
freq.addValue(j);
}
final long[] observed = new long[binCount];
for (int i = 0; i < binCount; i++) {
observed[i] = freq.getCount(i);
}
final double[] expected = new double[binCount];
for (int i = 0; i < binCount; i++) {
expected[i] = 1d / binCount;
}
TestUtils.assertChiSquareAccept(expected, observed, 0.01);
}
示例11: testNextLongDirect
import org.apache.commons.math3.stat.Frequency; //导入方法依赖的package包/类
@Test
public void testNextLongDirect() {
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 = generator.nextLong();
val = val < 0 ? -val : val;
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
*/
Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例12: testNextFloatDirect
import org.apache.commons.math3.stat.Frequency; //导入方法依赖的package包/类
@Test
public void testNextFloatDirect() {
Frequency freq = new Frequency();
float val = 0;
int value = 0;
for (int i=0; i<smallSampleSize; i++) {
val = generator.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
*/
Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
示例13: numberOfSubscales
import org.apache.commons.math3.stat.Frequency; //导入方法依赖的package包/类
public int numberOfSubscales(){
Frequency table = new Frequency();
for(VariableAttributes v : variables){
table.addValue(v.getItemGroup());
}
return table.getUniqueCount();
}
示例14: setNeutralOmegaDistribution
import org.apache.commons.math3.stat.Frequency; //导入方法依赖的package包/类
public void setNeutralOmegaDistribution(String neutralOmegaFile) throws IOException {
Frequency omegaDist = new Frequency();
BufferedReader br = new BufferedReader(new FileReader(neutralOmegaFile));
String line = null;
double lastTreeLength = -1;
int lineNum = 0;
while((line = br.readLine()) != null) {
lineNum++;
if(line.startsWith("#")) {
continue;
}
String [] lineInfo = line.split("\\s");
double omega = Double.parseDouble(lineInfo[1]);
double treeLength = Double.parseDouble(lineInfo[2]);
if(lineNum >1 && lastTreeLength != treeLength) {
throw new IllegalArgumentException("The neutral omega file must all be computed on the same tree, found two different tree lentgths in lines " + (lineNum - 1) + " and line " + lineNum);
}
lastTreeLength = treeLength;
omegaDist.addValue(omega);
}
br.close();
binStatistics = new LinkedHashMap<Double, Frequency>(1);
binStatistics.put(lastTreeLength, omegaDist);
}
示例15: ssGSEA
import org.apache.commons.math3.stat.Frequency; //导入方法依赖的package包/类
public ssGSEA(String geneset, String Studyfile) {
DataSetParse dp = new DataSetParse(Studyfile);
geneTermlist = dp.getDatalist();
genelist=dp.getGenelist();
BufferedReader br = null;
String str[]=geneset.split("\t");
genesetname =str[0];
for (int i = 2; i < str.length; i++) {
signatureList.add(str[i]);
}
ArrayList<GeneDataTerm> hitTermlist = new ArrayList<GeneDataTerm>();
for (int i = 0; i < genelist.size(); i++) {
if (signatureList.contains(genelist.get(i))) {
Nhit++;
sumhitFC += geneTermlist.get(i).getFoldChange();
hitmap.put(genelist.get(i), "TRUE");
} else {
hitmap.put(genelist.get(i), "FALSE");
}
}
Ntotal = geneTermlist.size();
kmiss=(double)(1 / (Ntotal - Nhit));
orginES=getSetES( geneTermlist);;
Frequency f=new Frequency();
for (int i = 0; i < permutation; i++) {
shuffleGeneDataTermlist(geneTermlist);
// System.out.print(geneTermlist.get(1).getGeneName());
f.addValue(getSetES(geneTermlist));
// System.out.println(getSetES(geneTermlist));
}
pvalue=(double)(100-f.getCumFreq(orginES))/100;
}