1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.orekit.estimation.common;
19
20 import org.hipparchus.stat.descriptive.StreamingStatistics;
21 import org.orekit.estimation.measurements.EstimatedMeasurement;
22 import org.orekit.estimation.measurements.ObservedMeasurement;
23
24 import java.io.PrintStream;
25 import java.util.Comparator;
26 import java.util.SortedSet;
27 import java.util.TreeSet;
28
29
30
31
32
33 abstract class MeasurementLog<T extends ObservedMeasurement<T>> implements EvaluationLogger<T> {
34
35
36 private final SortedSet<EstimatedMeasurement<T>> evaluations;
37
38
39
40 MeasurementLog() {
41 this.evaluations = new TreeSet<EstimatedMeasurement<T>>(Comparator.naturalOrder());
42 }
43
44
45
46
47
48 abstract double residual(EstimatedMeasurement<T> evaluation);
49
50
51 @Override
52 public void log(final EstimatedMeasurement<T> evaluation) {
53 evaluations.add(evaluation);
54 }
55
56
57
58 StreamingStatistics createStatisticsSummary() {
59
60 if (evaluations.isEmpty()) {
61 return null;
62 }
63
64
65 final StreamingStatistics stats = new StreamingStatistics();
66 for (final EstimatedMeasurement<T> evaluation : evaluations) {
67 stats.addValue(residual(evaluation));
68 }
69 return stats;
70
71 }
72
73
74
75
76 public void displaySummary(final PrintStream logStream) {
77 if (!evaluations.isEmpty()) {
78
79
80 final StreamingStatistics stats = createStatisticsSummary();
81
82
83 final String name = evaluations.first().getObservedMeasurement().getClass().getSimpleName();
84 logStream.println("Measurements type: " + name);
85 logStream.println(" number of measurements: " + stats.getN() + "/" + evaluations.size());
86 logStream.println(" residuals min value : " + stats.getMin());
87 logStream.println(" residuals max value : " + stats.getMax());
88 logStream.println(" residuals mean value : " + stats.getMean());
89 logStream.println(" residuals σ : " + stats.getStandardDeviation());
90 logStream.println(" residuals median : " + stats.getMedian());
91
92 }
93 }
94
95 }