use of org.apache.commons.math3.stat.descriptive.StatisticalSummary in project GDSC-SMLM by aherbert.
the class PSFEstimator method checkAngleSignificance.
private boolean checkAngleSignificance() {
boolean tryAgain = false;
if (ignore[ANGLE])
return tryAgain;
// The angle is relative to the major axis (X).
// It could be close to 0, 90 or 180 to allow it to be ignored in favour of a free circular function.
final double[] angles = sampleNew[ANGLE].getValues();
for (double testAngle : new double[] { 90, 0, 180 }) {
// The angle will be in the 0-180 domain.
// We need to compute the Statistical summary around the testAngle.
StatisticalSummary sampleStats;
if (testAngle == 0 || testAngle == 180) {
SummaryStatistics stats = new SummaryStatistics();
boolean zeroAngle = (testAngle == 0);
for (double a : angles) {
if (zeroAngle) {
// Convert to -90-90 domain
if (a > 90)
a -= 180;
} else {
// Convert to 90-270 domain
if (a < 90)
a += 180;
}
stats.addValue(a);
}
sampleStats = stats;
} else {
// Already in the 0-180 domain around the angle 90
sampleStats = sampleNew[ANGLE];
}
final double p = TestUtils.tTest(testAngle, sampleStats);
if (p > settings.pValue) {
log("NOTE: Angle is not significant: %g ~ %g (p=%g) => Re-run with fixed zero angle", sampleStats.getMean(), testAngle, p);
ignore[ANGLE] = true;
config.getFitConfiguration().setFitFunction(FitFunction.FREE_CIRCULAR);
tryAgain = true;
break;
} else
debug(" NOTE: Angle is significant: %g !~ %g (p=%g)", sampleNew[ANGLE].getMean(), testAngle, p);
}
return tryAgain;
}
use of org.apache.commons.math3.stat.descriptive.StatisticalSummary in project lucene-solr by apache.
the class EmpiricalDistributionEvaluator method evaluate.
public Tuple evaluate(Tuple tuple) throws IOException {
if (subEvaluators.size() != 1) {
throw new IOException("Empirical dist expects 1 column as a parameters");
}
StreamEvaluator colEval1 = subEvaluators.get(0);
List<Number> numbers1 = (List<Number>) colEval1.evaluate(tuple);
double[] column1 = new double[numbers1.size()];
for (int i = 0; i < numbers1.size(); i++) {
column1[i] = numbers1.get(i).doubleValue();
}
Arrays.sort(column1);
EmpiricalDistribution empiricalDistribution = new EmpiricalDistribution();
empiricalDistribution.load(column1);
Map map = new HashMap();
StatisticalSummary statisticalSummary = empiricalDistribution.getSampleStats();
map.put("max", statisticalSummary.getMax());
map.put("mean", statisticalSummary.getMean());
map.put("min", statisticalSummary.getMin());
map.put("stdev", statisticalSummary.getStandardDeviation());
map.put("sum", statisticalSummary.getSum());
map.put("N", statisticalSummary.getN());
map.put("var", statisticalSummary.getVariance());
return new EmpiricalDistributionTuple(empiricalDistribution, column1, map);
}
use of org.apache.commons.math3.stat.descriptive.StatisticalSummary in project lucene-solr by apache.
the class HistogramEvaluator method evaluate.
public List<Map> evaluate(Tuple tuple) throws IOException {
StreamEvaluator colEval1 = subEvaluators.get(0);
List<Number> numbers1 = (List<Number>) colEval1.evaluate(tuple);
double[] column1 = new double[numbers1.size()];
for (int i = 0; i < numbers1.size(); i++) {
column1[i] = numbers1.get(i).doubleValue();
}
int bins = 10;
if (subEvaluators.size() == 2) {
StreamEvaluator binsEval = subEvaluators.get(1);
Number binsNum = (Number) binsEval.evaluate(tuple);
bins = binsNum.intValue();
}
EmpiricalDistribution empiricalDistribution = new EmpiricalDistribution(bins);
empiricalDistribution.load(column1);
List<Map> binList = new ArrayList();
List<SummaryStatistics> summaries = empiricalDistribution.getBinStats();
for (SummaryStatistics statisticalSummary : summaries) {
Map map = new HashMap();
map.put("max", statisticalSummary.getMax());
map.put("mean", statisticalSummary.getMean());
map.put("min", statisticalSummary.getMin());
map.put("stdev", statisticalSummary.getStandardDeviation());
map.put("sum", statisticalSummary.getSum());
map.put("N", statisticalSummary.getN());
map.put("var", statisticalSummary.getVariance());
binList.add(map);
}
return binList;
}
Aggregations