本文整理汇总了Java中org.apache.commons.math.stat.descriptive.SummaryStatistics类的典型用法代码示例。如果您正苦于以下问题:Java SummaryStatistics类的具体用法?Java SummaryStatistics怎么用?Java SummaryStatistics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SummaryStatistics类属于org.apache.commons.math.stat.descriptive包,在下文中一共展示了SummaryStatistics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
@Override
public void init() {
checkedInLookUpMap = new HashMap<Actor, Integer>();
checkedOutLookUpMap = new HashMap<Actor, Integer>();
failedInLookUpMap = new HashMap<Actor, Integer>();
failedOutLookUpMap = new HashMap<Actor, Integer>();
checkedPartitionCounters = HashMultiset.create();
failedPartitionCounters = HashMultiset.create();
checkedConditionsStatistics = new HashMap<Actor, SummaryStatistics>();
failedConditionsStatistics = new HashMap<Actor, SummaryStatistics>();
for (Actor actor : network.getActors()) {
checkedInLookUpMap.put(actor, 0);
checkedOutLookUpMap.put(actor, 0);
failedInLookUpMap.put(actor, 0);
failedOutLookUpMap.put(actor, 0);
checkedConditionsStatistics.put(actor, new SummaryStatistics());
failedConditionsStatistics.put(actor, new SummaryStatistics());
}
}
示例2: getClassToObject
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
private SummaryStatistics getClassToObject() {
SummaryStatistics summary = new SummaryStatistics();
HashSet<String> classNameSet = new HashSet<String>();
for (GraphMetricItem gmi : listOfObjects.values()) {
// HACK: displayTypeName is not uniquely identified
// HACK: using gmi.declaredTypeName is a workaround, but some
// declared types are imprecise. See Hashtable<K, List<V>> in PX
classNameSet.add(gmi.declaredTypeName);
}
// System.out.println("classes that have more than one representative in the object graph");
for (String className : classNameSet) {
long count = 0;
for (GraphMetricItem gmj : listOfObjects.values()) {
if (gmj.declaredTypeName.equals(className)){
count++;
// if (count>1)
// System.out.println(gmj.declaredTypeName);
}
}
summary.addValue(count);
}
return summary;
}
示例3: computeStatistics
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public static SummaryStatistics computeStatistics(UnexpectednessScorer scorer) {
int numNodes = scorer.graph.numNodes();
SummaryStatistics stats = new SummaryStatistics();
ProgressLogger pl = new ProgressLogger(LOGGER, "docs");
pl.expectedUpdates = numNodes;
pl.start("Finding statistics for values of " + scorer + "...");
for (int i = 0; i < numNodes; i++) {
for (double x : scorer.scores(i).values()) {
stats.addValue(x);
if (Double.isInfinite(x) || Double.isNaN(x))
throw new ArithmeticException(
"Scorer " + scorer + " has returned value "
+ x + " for a result of document " + i);
}
pl.lightUpdate();
}
pl.done();
return stats;
}
示例4: computeApproxStatistics
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public static SummaryStatistics computeApproxStatistics(UnexpectednessScorer scorer) {
int numNodes = scorer.graph.numNodes();
int sampleSize = 10000;
if (sampleSize > numNodes) sampleSize = numNodes;
SummaryStatistics stats = new SummaryStatistics();
ProgressLogger pl = new ProgressLogger(LOGGER, "docs");
pl.expectedUpdates = sampleSize;
pl.start("Finding statistics for values of " + scorer + " (sample of "+sampleSize+")...");
for (int i: RandomSingleton.get().ints(sampleSize, 0, numNodes).toArray()) {
for (double x : scorer.scores(i).values()) {
stats.addValue(x);
if (Double.isInfinite(x) || Double.isNaN(x))
throw new ArithmeticException(
"Scorer " + scorer + " has returned value "
+ x + " for a results of document " + i);
}
pl.lightUpdate();
}
pl.done();
LOGGER.info(scorer + " -- sample of " + numNodes + " -- " + stats.toString());
return stats;
}
示例5: save
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public static Properties save(SummaryStatistics stat, File file, String scorerSpec) throws IOException {
Properties prop = new Properties();
prop.setProperty("scorer", scorerSpec);
for (String line : stat.toString().split("\n")) {
String[] tokens = line.split(":", 2);
if (tokens.length == 2) {
tokens[0] = tokens[0].trim().replace(" ", "-");
tokens[1] = tokens[1].trim();
if (tokens[0].length() > 0 && tokens[1].length() > 0)
prop.setProperty(tokens[0], tokens[1]);
}
}
OutputStream out = new FileOutputStream(file);
String comments = SummaryStatistics.class.getSimpleName() + " saved by " + ScorerStatisticsSummarizer.class.getSimpleName();
prop.store(out, comments);
out.close();
return prop;
}
示例6: main
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public static void main(String[] rawArguments) throws JSAPException, IOException, ReflectiveOperationException {
SimpleJSAP jsap = new SimpleJSAP(
ScorerStatisticsSummarizer.class.getName(),
"Compute summary statistics for a scorer ",
new Parameter[] {
new UnflaggedOption( "scorer", JSAP.STRING_PARSER, JSAP.REQUIRED,
"Specification for the scorer" ),
new UnflaggedOption( "output", JSAP.STRING_PARSER, JSAP.REQUIRED,
"Filepath of the saved statistics summary, saved as a Property file." ),
});
// parse arguments
JSAPResult args = jsap.parse( rawArguments );
if ( jsap.messagePrinted() ) System.exit( 1 );
String scorerSpec = args.getString("scorer");
UnexpectednessScorer scorer = (UnexpectednessScorer) PoolSpecification.SCORER_PARSER.parse(scorerSpec);
SummaryStatistics stat = computeStatistics(scorer);
save(stat, new File(args.getString("output")), scorerSpec);
System.out.println(scorer + " " + stat);
}
示例7: 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");
}
示例8: testTwoSampleTHomoscedastic
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public void testTwoSampleTHomoscedastic() throws Exception {
double[] sample1 ={2, 4, 6, 8, 10, 97};
double[] sample2 = {4, 6, 8, 10, 16};
SummaryStatistics sampleStats1 = new SummaryStatistics();
for (int i = 0; i < sample1.length; i++) {
sampleStats1.addValue(sample1[i]);
}
SummaryStatistics sampleStats2 = new SummaryStatistics();
for (int i = 0; i < sample2.length; i++) {
sampleStats2.addValue(sample2[i]);
}
// Target comparison values computed using R version 1.8.1 (Linux version)
assertEquals("two sample homoscedastic t stat", 0.73096310086,
TestUtils.homoscedasticT(sample1, sample2), 10E-11);
assertEquals("two sample homoscedastic p value", 0.4833963785,
TestUtils.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);
assertTrue("two sample homoscedastic t-test reject",
TestUtils.homoscedasticTTest(sample1, sample2, 0.49));
assertTrue("two sample homoscedastic t-test accept",
!TestUtils.homoscedasticTTest(sample1, sample2, 0.48));
}
示例9: testTwoSampleTHomoscedastic
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public void testTwoSampleTHomoscedastic() throws Exception {
double[] sample1 ={2, 4, 6, 8, 10, 97};
double[] sample2 = {4, 6, 8, 10, 16};
SummaryStatistics sampleStats1 = new SummaryStatistics();
for (int i = 0; i < sample1.length; i++) {
sampleStats1.addValue(sample1[i]);
}
SummaryStatistics sampleStats2 = new SummaryStatistics();
for (int i = 0; i < sample2.length; i++) {
sampleStats2.addValue(sample2[i]);
}
// Target comparison values computed using R version 1.8.1 (Linux version)
assertEquals("two sample homoscedastic t stat", 0.73096310086,
testStatistic.homoscedasticT(sample1, sample2), 10E-11);
assertEquals("two sample homoscedastic p value", 0.4833963785,
testStatistic.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);
assertTrue("two sample homoscedastic t-test reject",
testStatistic.homoscedasticTTest(sample1, sample2, 0.49));
assertTrue("two sample homoscedastic t-test accept",
!testStatistic.homoscedasticTTest(sample1, sample2, 0.48));
}
示例10: testSummaryStatistics
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
/**
* Test SummaryStatistics - implementations that do not store the data
* and use single pass algorithms to compute statistics
*/
public void testSummaryStatistics() throws Exception {
SummaryStatistics u = new SummaryStatistics();
loadStats("data/PiDigits.txt", u);
assertEquals("PiDigits: std", std, u.getStandardDeviation(), 1E-13);
assertEquals("PiDigits: mean", mean, u.getMean(), 1E-13);
loadStats("data/Mavro.txt", u);
assertEquals("Mavro: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("Mavro: mean", mean, u.getMean(), 1E-14);
loadStats("data/Michelso.txt", u);
assertEquals("Michelso: std", std, u.getStandardDeviation(), 1E-13);
assertEquals("Michelso: mean", mean, u.getMean(), 1E-13);
loadStats("data/NumAcc1.txt", u);
assertEquals("NumAcc1: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("NumAcc1: mean", mean, u.getMean(), 1E-14);
loadStats("data/NumAcc2.txt", u);
assertEquals("NumAcc2: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("NumAcc2: mean", mean, u.getMean(), 1E-14);
}
示例11: 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);
}
示例12: M_F1
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public M_F1() {
super();
sumStats = new SummaryStatistics();
//Precision
correctHits = 0;
queryVal = 0;
overallRes = 0;
overallQueries = 0;
itemsRetrieved = new HashMap<Integer, Integer>();
//Recall
map = new HashMap<Integer, Integer>();
classname = new String[3];
classname[0] = "F1";
classname[1] = "F1_StandardDeviation";
classname[2] = "F1_Variance";
}
示例13: analyseImage
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
@Override
public void analyseImage(FImage image) {
final FImage limg = image.process(laplacian);
final FImage aimg = image.process(average);
final SummaryStatistics stats = new SummaryStatistics();
for (int r = 0; r < limg.height; r++) {
for (int c = 0; c < limg.width; c++) {
if (mask != null && mask.pixels[r][c] == 0)
continue;
if (aimg.pixels[r][c] != 0) {
stats.addValue(Math.abs(limg.pixels[r][c] / aimg.pixels[r][c]));
}
}
}
sharpnessVariation = stats.getStandardDeviation();
}
示例14: runExperiment
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public static synchronized ExperimentContext runExperiment(RunnableExperiment experiment) {
Set<Reference> oldRefs = ReferenceListener.reset();
Map<String, SummaryStatistics> oldTimes = TimeTracker.reset();
ExperimentContext context = new ExperimentContext(experiment);
runSetup(experiment);
runPerform(experiment);
runFinish(experiment, context);
context.lock();
ReferenceListener.addReferences(oldRefs);
TimeTracker.addMissing(oldTimes);
return context;
}
示例15: testTwoSampleTHomoscedastic
import org.apache.commons.math.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public void testTwoSampleTHomoscedastic() throws Exception {
double[] sample1 ={2, 4, 6, 8, 10, 97};
double[] sample2 = {4, 6, 8, 10, 16};
SummaryStatistics sampleStats1 = new SummaryStatistics();
for (int i = 0; i < sample1.length; i++) {
sampleStats1.addValue(sample1[i]);
}
SummaryStatistics sampleStats2 = new SummaryStatistics();
for (int i = 0; i < sample2.length; i++) {
sampleStats2.addValue(sample2[i]);
}
// Target comparison values computed using R version 1.8.1 (Linux version)
assertEquals("two sample homoscedastic t stat", 0.73096310086,
TestUtils.homoscedasticT(sample1, sample2), 10E-11);
assertEquals("two sample homoscedastic p value", 0.4833963785,
TestUtils.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);
assertTrue("two sample homoscedastic t-test reject",
TestUtils.homoscedasticTTest(sample1, sample2, 0.49));
assertTrue("two sample homoscedastic t-test accept",
!TestUtils.homoscedasticTTest(sample1, sample2, 0.48));
}