The Sparta Modeling Framework
Loading...
Searching...
No Matches
CustomHistogramStats.hpp
1
2#pragma once
3
6
14// in regular and over/under flow bins.
15double stdev_x3(const sparta::CycleHistogramTreeNode* h)
16{
17 return (h->getStandardDeviation()) * 3;
18}
19
21// count greater than twice the standard deviation.
22double fraction_coverage_greaterThan2StdDev(const sparta::CycleHistogramTreeNode* h)
23{
24 double total = 0.0;
25 const double std_dev = h->getStandardDeviation();
26 const auto& bin_probs = h->recomputeRegularBinProbabilities();
27 const double uf = h->getUnderflowBin();
28 const double uf_p = h->getUnderflowProbability();
29 const double of = h->getOverflowBin();
30 const double of_p = h->getOverflowProbability();
31 const auto& bin_counts = h->getRegularBin();
32 for(size_t i = 0; i < bin_probs.size(); ++i){
33 if(bin_counts[i] > (2*std_dev)){
34 total += bin_probs[i];
35 }
36 }
37 if(uf > (2*std_dev)){
38 total += uf_p;
39 }
40 if(of > (2*std_dev)){
41 total += of_p;
42 }
43 return total;
44}
45
47// count between mean plus SD and mean plus twice SD.
48double fraction_coverage_mean_p_StdDev_mean_p_2StdDev(const sparta::CycleHistogramTreeNode* h)
49{
50 double total = 0.0;
51 const double std_dev = h->getStandardDeviation();
52 const double mean = h->getMeanBinCount();
53 const double left_interval = mean + std_dev;
54 const double right_interval = mean + (2 * std_dev);
55 const auto& bin_probs = h->recomputeRegularBinProbabilities();
56 const auto& bin_counts = h->getRegularBin();
57 const double uf = h->getUnderflowBin();
58 const double uf_p = h->getUnderflowProbability();
59 const double of = h->getOverflowBin();
60 const double of_p = h->getOverflowProbability();
61 for(size_t i = 0; i < bin_probs.size(); ++i){
62 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
63 total += bin_probs[i];
64 }
65 }
66 if(uf > left_interval && uf <= right_interval){
67 total += uf_p;
68 }
69 if(of > left_interval && of <= right_interval){
70 total += of_p;
71 }
72 return total;
73}
74
76// count between mean and mean plus SD.
77double fraction_coverage_mean_mean_p_StdDev(const sparta::CycleHistogramTreeNode* h)
78{
79 double total = 0.0;
80 const double std_dev = h->getStandardDeviation();
81 const double mean = h->getMeanBinCount();
82 const double left_interval = mean;
83 const double right_interval = mean + std_dev;
84 const auto& bin_probs = h->recomputeRegularBinProbabilities();
85 const auto& bin_counts = h->getRegularBin();
86 const double uf = h->getUnderflowBin();
87 const double uf_p = h->getUnderflowProbability();
88 const double of = h->getOverflowBin();
89 const double of_p = h->getOverflowProbability();
90 for(size_t i = 0; i < bin_probs.size(); ++i){
91 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
92 total += bin_probs[i];
93 }
94 }
95 if(uf > left_interval && uf <= right_interval){
96 total += uf_p;
97 }
98 if(of > left_interval && of <= right_interval){
99 total += of_p;
100 }
101 return total;
102}
103
105// count between mean minus SD and mean.
106double fraction_coverage_mean_m_StdDev_mean(const sparta::CycleHistogramTreeNode* h)
107{
108 double total = 0.0;
109 const double std_dev = h->getStandardDeviation();
110 const double mean = h->getMeanBinCount();
111 const double left_interval = mean - std_dev;
112 const double right_interval = mean;
113 const auto& bin_probs = h->recomputeRegularBinProbabilities();
114 const auto& bin_counts = h->getRegularBin();
115 const double uf = h->getUnderflowBin();
116 const double uf_p = h->getUnderflowProbability();
117 const double of = h->getOverflowBin();
118 const double of_p = h->getOverflowProbability();
119 for(size_t i = 0; i < bin_probs.size(); ++i){
120 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
121 total += bin_probs[i];
122 }
123 }
124 if(uf > left_interval && uf <= right_interval){
125 total += uf_p;
126 }
127 if(of > left_interval && of <= right_interval){
128 total += of_p;
129 }
130 return total;
131}
132
134// count between mean minus twice SD and mean minus SD.
135double fraction_coverage_mean_m_2StdDev_mean_m_StdDev(const sparta::CycleHistogramTreeNode* h)
136{
137 double total = 0.0;
138 const double std_dev = h->getStandardDeviation();
139 const double mean = h->getMeanBinCount();
140 const double left_interval = mean - (2 * std_dev);
141 const double right_interval = mean - std_dev;
142 const auto& bin_probs = h->recomputeRegularBinProbabilities();
143 const auto& bin_counts = h->getRegularBin();
144 const double uf = h->getUnderflowBin();
145 const double uf_p = h->getUnderflowProbability();
146 const double of = h->getOverflowBin();
147 const double of_p = h->getOverflowProbability();
148 for(size_t i = 0; i < bin_probs.size(); ++i){
149 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
150 total += bin_probs[i];
151 }
152 }
153 if(uf > left_interval && uf <= right_interval){
154 total += uf_p;
155 }
156 if(of > left_interval && of <= right_interval){
157 total += of_p;
158 }
159 return total;
160}
161
163// count lesser than twice SD.
164double fraction_coverage_lesserThan2StdDev(const sparta::CycleHistogramTreeNode* h)
165{
166 double total = 0.0;
167 const double std_dev = h->getStandardDeviation();
168 const auto& bin_probs = h->recomputeRegularBinProbabilities();
169 const double uf = h->getUnderflowBin();
170 const double uf_p = h->getUnderflowProbability();
171 const double of = h->getOverflowBin();
172 const double of_p = h->getOverflowProbability();
173 const auto& bin_counts = h->getRegularBin();
174 for(size_t i = 0; i < bin_probs.size(); ++i){
175 if(bin_counts[i] < (2*std_dev)){
176 total += bin_probs[i];
177 }
178 }
179 if(uf < (2*std_dev)){
180 total += uf_p;
181 }
182 if(of < (2*std_dev)){
183 total += of_p;
184 }
185 return total;
186}
187
189// in regular and over/under flow bins.
190double stdev_x3_h(const sparta::HistogramTreeNode* h)
191{
192 return (h->getStandardDeviation()) * 3;
193}
194
196// count greater than twice the standard deviation.
197double fraction_coverage_greaterThan2StdDev_h(const sparta::HistogramTreeNode* h)
198{
199 double total = 0.0;
200 const double std_dev = h->getStandardDeviation();
201 const auto& bin_probs = h->recomputeRegularBinProbabilities();
202 const double uf = h->getUnderflowBin();
203 const double uf_p = h->getUnderflowProbability();
204 const double of = h->getOverflowBin();
205 const double of_p = h->getOverflowProbability();
206 const auto& bin_counts = h->getRegularBin();
207 for(size_t i = 0; i < bin_probs.size(); ++i){
208 if(bin_counts[i] > (2*std_dev)){
209 total += bin_probs[i];
210 }
211 }
212 if(uf > (2*std_dev)){
213 total += uf_p;
214 }
215 if(of > (2*std_dev)){
216 total += of_p;
217 }
218 return total;
219}
220
222// count between mean plus SD and mean plus twice SD.
223double fraction_coverage_mean_p_StdDev_mean_p_2StdDev_h(const sparta::HistogramTreeNode* h)
224{
225 double total = 0.0;
226 const double std_dev = h->getStandardDeviation();
227 const double mean = h->getMeanBinCount();
228 const double left_interval = mean + std_dev;
229 const double right_interval = mean + (2 * std_dev);
230 const auto& bin_probs = h->recomputeRegularBinProbabilities();
231 const auto& bin_counts = h->getRegularBin();
232 const double uf = h->getUnderflowBin();
233 const double uf_p = h->getUnderflowProbability();
234 const double of = h->getOverflowBin();
235 const double of_p = h->getOverflowProbability();
236 for(size_t i = 0; i < bin_probs.size(); ++i){
237 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
238 total += bin_probs[i];
239 }
240 }
241 if(uf > left_interval && uf <= right_interval){
242 total += uf_p;
243 }
244 if(of > left_interval && of <= right_interval){
245 total += of_p;
246 }
247 return total;
248}
249
251// count between mean and mean plus SD.
252double fraction_coverage_mean_mean_p_StdDev_h(const sparta::HistogramTreeNode* h)
253{
254 double total = 0.0;
255 const double std_dev = h->getStandardDeviation();
256 const double mean = h->getMeanBinCount();
257 const double left_interval = mean;
258 const double right_interval = mean + std_dev;
259 const auto& bin_probs = h->recomputeRegularBinProbabilities();
260 const auto& bin_counts = h->getRegularBin();
261 const double uf = h->getUnderflowBin();
262 const double uf_p = h->getUnderflowProbability();
263 const double of = h->getOverflowBin();
264 const double of_p = h->getOverflowProbability();
265 for(size_t i = 0; i < bin_probs.size(); ++i){
266 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
267 total += bin_probs[i];
268 }
269 }
270 if(uf > left_interval && uf <= right_interval){
271 total += uf_p;
272 }
273 if(of > left_interval && of <= right_interval){
274 total += of_p;
275 }
276 return total;
277}
278
280// count between mean minus SD and mean.
281double fraction_coverage_mean_m_StdDev_mean_h(const sparta::HistogramTreeNode* h)
282{
283 double total = 0.0;
284 const double std_dev = h->getStandardDeviation();
285 const double mean = h->getMeanBinCount();
286 const double left_interval = mean - std_dev;
287 const double right_interval = mean;
288 const auto& bin_probs = h->recomputeRegularBinProbabilities();
289 const auto& bin_counts = h->getRegularBin();
290 const double uf = h->getUnderflowBin();
291 const double uf_p = h->getUnderflowProbability();
292 const double of = h->getOverflowBin();
293 const double of_p = h->getOverflowProbability();
294 for(size_t i = 0; i < bin_probs.size(); ++i){
295 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
296 total += bin_probs[i];
297 }
298 }
299 if(uf > left_interval && uf <= right_interval){
300 total += uf_p;
301 }
302 if(of > left_interval && of <= right_interval){
303 total += of_p;
304 }
305 return total;
306}
307
309// count between mean minus twice SD and mean minus SD.
310double fraction_coverage_mean_m_2StdDev_mean_m_StdDev_h(const sparta::HistogramTreeNode* h)
311{
312 double total = 0.0;
313 const double std_dev = h->getStandardDeviation();
314 const double mean = h->getMeanBinCount();
315 const double left_interval = mean - (2 * std_dev);
316 const double right_interval = mean - std_dev;
317 const auto& bin_probs = h->recomputeRegularBinProbabilities();
318 const auto& bin_counts = h->getRegularBin();
319 const double uf = h->getUnderflowBin();
320 const double uf_p = h->getUnderflowProbability();
321 const double of = h->getOverflowBin();
322 const double of_p = h->getOverflowProbability();
323 for(size_t i = 0; i < bin_probs.size(); ++i){
324 if(bin_counts[i] > left_interval && bin_counts[i] <= right_interval){
325 total += bin_probs[i];
326 }
327 }
328 if(uf > left_interval && uf <= right_interval){
329 total += uf_p;
330 }
331 if(of > left_interval && of <= right_interval){
332 total += of_p;
333 }
334 return total;
335}
336
338// count lesser than twice SD.
339double fraction_coverage_lesserThan2StdDev_h(const sparta::HistogramTreeNode* h)
340{
341 double total = 0.0;
342 const double std_dev = h->getStandardDeviation();
343 const auto& bin_probs = h->recomputeRegularBinProbabilities();
344 const double uf = h->getUnderflowBin();
345 const double uf_p = h->getUnderflowProbability();
346 const double of = h->getOverflowBin();
347 const double of_p = h->getOverflowProbability();
348 const auto& bin_counts = h->getRegularBin();
349 for(size_t i = 0; i < bin_probs.size(); ++i){
350 if(bin_counts[i] < (2*std_dev)){
351 total += bin_probs[i];
352 }
353 }
354 if(uf < (2*std_dev)){
355 total += uf_p;
356 }
357 if(of < (2*std_dev)){
358 total += of_p;
359 }
360 return total;
361}
CycleHistogram implementation using sparta CycleCounter.
Histogram implementation using sparta Counters.
double getStandardDeviation() const
Calculate Standard Deviation of counts in bins. This API also takes into account the count in underfl...
const sparta::CycleCounter & getOverflowBin() const
Return count of overflow bin.
const sparta::CycleCounter & getUnderflowBin() const
Return count of underflow bin.
double getUnderflowProbability() const
Return underflow probability.
double getOverflowProbability() const
Return overflow probability.
const std::vector< double > & recomputeRegularBinProbabilities() const
Return vector of probabilities regular bins.
double getMeanBinCount() const
Calculate the mean bin count of all the bins. This API also takes into account the count in underflow...
const std::vector< sparta::CycleCounter > & getRegularBin() const
Return vector of regular bin counts.
CycleHistogramTreeNode class for uint64_t values.
double getOverflowProbability() const
Return overflow probability.
const sparta::Counter & getUnderflowBin() const
Return count of underflow bin.
const std::vector< double > & recomputeRegularBinProbabilities() const
Return vector of probabilities regular bins.
double getStandardDeviation() const
Calculate Standard Deviation of counts in bins. This API also takes into account the count in underfl...
double getUnderflowProbability() const
Return underflow probability.
const sparta::Counter & getOverflowBin() const
Return count of overflow bin.
const std::vector< sparta::Counter > & getRegularBin() const
Return vector of regular bin counts.
double getMeanBinCount() const
Calculate the mean bin count of all the bins. This API also takes into account the count in underflow...