SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
HistogramOnly.java
1package umontreal.ssj.stat;
2
3import umontreal.ssj.util.PrintfFormat;
4
17public class HistogramOnly extends TallyHistogram implements Cloneable {
18
32 public HistogramOnly(double a, double b, int s) {
33 super(a, b, s);
34 }
35
44 public HistogramOnly(String name, double a, double b, int s) {
45 super(a, b, s);
46 this.name = name;
47 }
48
49 @Override
50 public void init() {
51 numObs = 0;
52 for (int i = 0; i < numBins; i++)
53 count[i] = 0;
54 }
55
62 public void add(double x) {
63 numObs++;
64 if ((x >= m_a) & (x <= m_b))
65 ++count[(int) ((x - m_a) / m_h)];
66 }
67
68 @Override
69 public double sum() {
70 throw new IllegalStateException("HistogramOnly.variance() is not supported.");
71 // return Double.NaN;
72 }
73
74 @Override
75 public double average() {
76 throw new IllegalStateException("HistogramOnly.variance() is not supported.");
77 // return Double.NaN;
78 }
79
80 @Override
81 public double variance() {
82 throw new IllegalStateException("HistogramOnly.variance() is not supported.");
83 // return Double.NaN;
84 }
85
90 HistogramOnly image = (HistogramOnly) super.clone();
91 return image;
92 }
93
97 public String toString() {
98 StringBuffer sb = new StringBuffer();
99 sb.append("---------------------------------------" + PrintfFormat.NEWLINE);
100 sb.append(name + PrintfFormat.NEWLINE);
101 sb.append("Interval = [ " + m_a + ", " + m_b + " ]" + PrintfFormat.NEWLINE);
102 sb.append("Number of bins = " + numBins + PrintfFormat.NEWLINE);
103 sb.append(PrintfFormat.NEWLINE + "Counters = {" + PrintfFormat.NEWLINE);
104 for (int i = 0; i < numBins; i++) {
105 double a = m_a + (i - 1) * m_h;
106 double b = m_a + i * m_h;
107 sb.append(" (" + PrintfFormat.f(6, 3, a) + ", " + PrintfFormat.f(6, 3, b) + ") " + count[i]
109 }
110 sb.append("}" + PrintfFormat.NEWLINE);
111 return sb.toString();
112 }
113
114 @Override
115 public String report() {
116 // TODO Auto-generated method stub
117 throw new IllegalStateException("HistogramOnly.report() is not supported.");
118 }
119
120 @Override
121 public String shortReport() {
122 // TODO Auto-generated method stub
123 throw new IllegalStateException("HistogramOnly.shortReport() is not supported.");
124 }
125
126 @Override
127 public String shortReportHeader() {
128 // TODO Auto-generated method stub
129 throw new IllegalStateException("HistogramOnly.shortReportHeader() is not supported.");
130 }
131
132}
double variance()
Returns the sample variance of the observations since the last initialization.
HistogramOnly(String name, double a, double b, int s)
Constructs a new HistogramOnly statistical probe with name name.
void add(double x)
Gives a new observation to the statistical collectors.
String shortReport()
Formats and returns a short statistical report for this tally.
String report()
Returns a formatted string that contains a report on this probe.
String shortReportHeader()
Returns a string containing the name of the values returned in the report strings.
double sum()
Returns the sum cumulated so far for this probe.
String toString()
Returns the bin counters as a String.
double average()
Returns the average value of the observations since the last initialization.
void init()
Initializes all the counters and accumulators, including those of the Tally object.
HistogramOnly(double a, double b, int s)
Constructs a HistogramOnly statistical probe.
HistogramOnly clone()
Clones this object and the array which stores the counters.
TallyHistogram(double a, double b, int numBins)
Constructs a TallyHistogram statistical probe.
This class acts like a StringBuffer which defines new types of append methods.
static String f(double x)
Same as f(0, 6, x).
static final String NEWLINE
End-of-line symbol or line separator.