本文整理汇总了Java中org.apache.commons.math.stat.descriptive.SummaryStatistics.getMean方法的典型用法代码示例。如果您正苦于以下问题:Java SummaryStatistics.getMean方法的具体用法?Java SummaryStatistics.getMean怎么用?Java SummaryStatistics.getMean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.stat.descriptive.SummaryStatistics
的用法示例。
在下文中一共展示了SummaryStatistics.getMean方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNextValue
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
* Generates a random value from this distribution.
*
* @return the random value.
* @throws IllegalStateException if the distribution has not been loaded
*/
public double getNextValue() throws IllegalStateException {
if (!loaded) {
throw new IllegalStateException("distribution not loaded");
}
// Start with a uniformly distributed random number in (0,1)
double x = Math.random();
// Use this to select the bin and generate a Gaussian within the bin
for (int i = 0; i < binCount; i++) {
if (x <= upperBounds[i]) {
SummaryStatistics stats = (SummaryStatistics)binStats.get(i);
if (stats.getN() > 0) {
if (stats.getStandardDeviation() > 0) { // more than one obs
return randomData.nextGaussian
(stats.getMean(),stats.getStandardDeviation());
} else {
return stats.getMean(); // only one obs in bin
}
}
}
}
throw new RuntimeException("No bin selected");
}
示例2: testNextGaussian
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
public void testNextGaussian() {
try {
randomData.nextGaussian(0,0);
fail("zero sigma -- IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
SummaryStatistics u = new SummaryStatistics();
for (int i = 0; i<largeSampleSize; i++) {
u.addValue(randomData.nextGaussian(0,1));
}
double xbar = u.getMean();
double s = u.getStandardDeviation();
double n = (double) u.getN();
/* t-test at .001-level TODO: replace with externalized t-test, with
* test statistic defined in TestStatistic
*/
assertTrue(Math.abs(xbar)/(s/Math.sqrt(n))< 3.29);
}
示例3: checkValues
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
private static double checkValues(List<Integer> values) {
System.out.println("Values: " + values);
SummaryStatistics ss = new SummaryStatistics();
for (int i=0; i<values.size(); i++) {
ss.addValue(values.get(i));
}
double mean = ss.getMean();
double stddev = ss.getStandardDeviation();
double p = ((stddev*100)/mean);
System.out.println("Percentage diff: " + p);
Assert.assertTrue("" + p + " " + values, p<0.1);
return p;
}
示例4: getNextValue
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
* Generates a random value from this distribution.
*
* @return the random value.
* @throws IllegalStateException if the distribution has not been loaded
*/
public double getNextValue() throws IllegalStateException {
if (!loaded) {
throw MathRuntimeException.createIllegalStateException("distribution not loaded");
}
// Start with a uniformly distributed random number in (0,1)
double x = Math.random();
// Use this to select the bin and generate a Gaussian within the bin
for (int i = 0; i < binCount; i++) {
if (x <= upperBounds[i]) {
SummaryStatistics stats = binStats.get(i);
if (stats.getN() > 0) {
if (stats.getStandardDeviation() > 0) { // more than one obs
return randomData.nextGaussian
(stats.getMean(),stats.getStandardDeviation());
} else {
return stats.getMean(); // only one obs in bin
}
}
}
}
throw new MathRuntimeException("no bin selected");
}
示例5: testNextGaussian
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
public void testNextGaussian() {
try {
randomData.nextGaussian(0, 0);
fail("zero sigma -- IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// ignored
}
SummaryStatistics u = new SummaryStatistics();
for (int i = 0; i < largeSampleSize; i++) {
u.addValue(randomData.nextGaussian(0, 1));
}
double xbar = u.getMean();
double s = u.getStandardDeviation();
double n = u.getN();
/*
* t-test at .001-level TODO: replace with externalized t-test, with
* test statistic defined in TestStatistic
*/
assertTrue(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29);
}
示例6: testNextGaussian
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
public void testNextGaussian() {
try {
randomData.nextGaussian(0, 0);
fail("zero sigma -- MathIllegalArgumentException expected");
} catch (MathIllegalArgumentException ex) {
// ignored
}
SummaryStatistics u = new SummaryStatistics();
for (int i = 0; i < largeSampleSize; i++) {
u.addValue(randomData.nextGaussian(0, 1));
}
double xbar = u.getMean();
double s = u.getStandardDeviation();
double n = u.getN();
/*
* t-test at .001-level TODO: replace with externalized t-test, with
* test statistic defined in TestStatistic
*/
assertTrue(FastMath.abs(xbar) / (s / FastMath.sqrt(n)) < 3.29);
}
示例7: testNextGaussian
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
public void testNextGaussian() {
try {
randomData.nextGaussian(0, 0);
fail("zero sigma -- IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// ignored
}
SummaryStatistics u = new SummaryStatistics();
for (int i = 0; i < largeSampleSize; i++) {
u.addValue(randomData.nextGaussian(0, 1));
}
double xbar = u.getMean();
double s = u.getStandardDeviation();
double n = u.getN();
/*
* t-test at .001-level TODO: replace with externalized t-test, with
* test statistic defined in TestStatistic
*/
assertTrue(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29);
}
示例8: testNextGaussian
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
@Test
public void testNextGaussian() {
try {
randomData.nextGaussian(0, 0);
Assert.fail("zero sigma -- MathIllegalArgumentException expected");
} catch (MathIllegalArgumentException ex) {
// ignored
}
SummaryStatistics u = new SummaryStatistics();
for (int i = 0; i < largeSampleSize; i++) {
u.addValue(randomData.nextGaussian(0, 1));
}
double xbar = u.getMean();
double s = u.getStandardDeviation();
double n = u.getN();
/*
* t-test at .001-level TODO: replace with externalized t-test, with
* test statistic defined in TestStatistic
*/
Assert.assertTrue(FastMath.abs(xbar) / (s / FastMath.sqrt(n)) < 3.29);
}
示例9: testNextGaussian
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/** test failure modes and distribution of nextGaussian() */
public void testNextGaussian() {
try {
double x = randomData.nextGaussian(0,0);
fail("zero sigma -- IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
;
}
SummaryStatistics u = SummaryStatistics.newInstance();
for (int i = 0; i<largeSampleSize; i++) {
u.addValue(randomData.nextGaussian(0,1));
}
double xbar = u.getMean();
double s = u.getStandardDeviation();
double n = (double) u.getN();
/* t-test at .001-level TODO: replace with externalized t-test, with
* test statistic defined in TestStatistic
*/
assertTrue(Math.abs(xbar)/(s/Math.sqrt(n))< 3.29);
}
示例10: getNextValue
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
/**
* Generates a random value from this distribution.
*
* @return the random value.
* @throws IllegalStateException if the distribution has not been loaded
*/
public double getNextValue() throws IllegalStateException {
if (!loaded) {
throw MathRuntimeException.createIllegalStateException("distribution not loaded");
}
// Start with a uniformly distributed random number in (0,1)
double x = Math.random();
// Use this to select the bin and generate a Gaussian within the bin
for (int i = 0; i < binCount; i++) {
if (x <= upperBounds[i]) {
SummaryStatistics stats = binStats.get(i);
if (stats.getN() > 0) {
if (stats.getStandardDeviation() > 0) { // more than one obs
return randomData.nextGaussian
(stats.getMean(),stats.getStandardDeviation());
} else {
return stats.getMean(); // only one obs in bin
}
}
}
}
throw new MathRuntimeException("no bin selected");
}
示例11: analyzeResults
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
@Override
public boolean analyzeResults(PageRankWithPriors<Vertex, Edge> pr) {
boolean disambiguationStop = true;
Collection<Vertex> vertexCol = graph.getVertices();
for (int i = 0; i < repList.size(); i++) {
if (!disambiguatedSurfaceForms.get(i)) {
int qryNr = repList.get(i).getQueryNr();
double maxScore = 0;
SummaryStatistics stats = new SummaryStatistics();
String tempSolution = "";
List<Candidate> scores = new ArrayList<Candidate>();
for (Vertex v : vertexCol) {
if (v.getEntityQuery() == qryNr && v.isCandidate()) {
scores.add(new Candidate(pr.getVertexScore(v)));
double score = Math.abs(pr.getVertexScore(v));
stats.addValue(score);
System.out.println("Score for: "+v.getUris().get(0)+" : "+score);
if (score > maxScore) {
tempSolution = v.getUris().get(0);
maxScore = score;
}
}
}
SurfaceForm rep = repList.get(i);
Collections.sort(scores, Collections.reverseOrder());
double secondMax = scores.get(1).score;
if (!Double.isInfinite(maxScore)) {
double avg = stats.getMean();
double threshold = computeThreshold(avg, maxScore);
// if (secondMax < threshold) {
updateGraph(rep.getCandidates(), tempSolution,
rep.getQueryNr());
rep.setDisambiguatedEntity(tempSolution);
System.out.println("Ich disambiguiere: "+tempSolution);
disambiguatedSurfaceForms.set(i);
disambiguationStop = false;
break;
}
// }
}
}
return disambiguationStop;
}
示例12: analyzeResults
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
@Override
public boolean analyzeResults(PageRankWithPriors<Vertex, Edge> pr) {
boolean disambiguationStop = true;
Collection<Vertex> vertexCol = graph.getVertices();
for (int i = 0; i < repList.size(); i++) {
if (!disambiguatedSurfaceForms.get(i) && repList.get(i).isRelevant()) {
int qryNr = repList.get(i).getQueryNr();
double maxScore = 0;
SummaryStatistics stats = new SummaryStatistics();
String tempSolution = "";
List<Candidate> scores = new ArrayList<Candidate>();
for (Vertex v : vertexCol) {
if (v.getEntityQuery() == qryNr && v.isCandidate()) {
scores.add(new Candidate(v.getUris().get(0), pr
.getVertexScore(v)));
double score = Math.abs(pr.getVertexScore(v));
stats.addValue(score);
if (score > maxScore) {
tempSolution = v.getUris().get(0);
maxScore = score;
}
}
}
SurfaceForm rep = repList.get(i);
SurfaceForm clone = origList.get(i);
Collections.sort(scores, Collections.reverseOrder());
double secondMax = scores.get(1).score;
List<String> newCandidates = new ArrayList<String>();
for(int j = 0; j < maximumcandidatespersf; j++) {
if(scores.size() > j) {
newCandidates.add(scores.get(j).can);
} else {
break;
}
}
if (!Double.isInfinite(maxScore)) {
double avg = stats.getMean();
double threshold = computeThreshold(avg, maxScore);
if (secondMax < threshold && disambiguate) {
updateGraph(rep.getCandidates(), tempSolution,
rep.getQueryNr());
rep.setDisambiguatedEntity(tempSolution);
clone.setDisambiguatedEntity(tempSolution);
disambiguatedSurfaceForms.set(i);
disambiguationStop = false;
break;
} else {
clone.setCandidates(newCandidates);
}
}
}
}
return disambiguationStop;
}
示例13: getValueFromSummaryStatistics
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入方法依赖的package包/类
double getValueFromSummaryStatistics(SummaryStatistics summaryStatistics) {
return summaryStatistics.getN()==0 ? 0 : summaryStatistics.getMean();
}