NCBI C++ ToolKit
Classes | Macros | Typedefs | Enumerations | Enumerator | Functions | Variables
Statistics

Classes

class  CHistogram< TValue, TScale, TCounter >
 CHistogram – collect the distribution of the numerical data samples. More...
 
class  CHistogramTimeSeries< TValue, TScale, TCounter >
 A series of same-structured histograms covering logarithmically (base 2) increasing time periods... More...
 
struct  CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin
 A histograms which covers a certain number of ticks. More...
 

Macros

#define RETURN_MT_SAFE(member)
 

Typedefs

template<typename T >
using T_HistogramValueTypeHavePlus = decltype((T &)(std::declval< T >().operator+=(std::declval< const T & >())))
 Helper types for CHistogram<>::GetSum() support. More...
 
using CHistogram< TValue, TScale, TCounter >::TIntegral = typename std::conditional< std::numeric_limits< TValue >::is_signed, int64_t, uint64_t >::type
 Sum type: double for all floating points TValue types, int64_t/uint64_t for integral, and TValue otherwise. More...
 
using CHistogram< TValue, TScale, TCounter >::TArithmetic = typename std::conditional< std::is_floating_point< TValue >::value, double, TIntegral >::type
 
using CHistogram< TValue, TScale, TCounter >::TSum = typename std::conditional< std::is_arithmetic< TValue >::value, TArithmetic, TValue >::type
 
using CHistogramTimeSeries< TValue, TScale, TCounter >::THistogram = CHistogram< TValue, TScale, TCounter >
 
using CHistogramTimeSeries< TValue, TScale, TCounter >::TTicks = unsigned int
 Type of the unit of time. More...
 
using CHistogramTimeSeries< TValue, TScale, TCounter >::TTimeBins = list< STimeBin >
 Type of the series of histograms. More...
 

Enumerations

enum  CHistogram< TValue, TScale, TCounter >::EScaleType { CHistogram< TValue, TScale, TCounter >::eLinear = 1 , CHistogram< TValue, TScale, TCounter >::eLog , CHistogram< TValue, TScale, TCounter >::eLog2 , CHistogram< TValue, TScale, TCounter >::eLog10 }
 Scale type. More...
 
enum  CHistogram< TValue, TScale, TCounter >::EScaleView { CHistogram< TValue, TScale, TCounter >::eMonotonic , CHistogram< TValue, TScale, TCounter >::eSymmetrical }
 Methods to build bins for a specified scale. More...
 
enum  CHistogram< TValue, TScale, TCounter >::EEstimateNumberOfBinsRule { CHistogram< TValue, TScale, TCounter >::eSquareRoot = 0 , CHistogram< TValue, TScale, TCounter >::eJuran , CHistogram< TValue, TScale, TCounter >::eSturge , CHistogram< TValue, TScale, TCounter >::eRice }
 Rules to calculate an estimated numbers of bins on the base of the expected number of observations. More...
 
enum  CHistogram< TValue, TScale, TCounter >::EClone { CHistogram< TValue, TScale, TCounter >::eCloneAll = 0 , CHistogram< TValue, TScale, TCounter >::eCloneStructureOnly }
 

Functions

template<typename T >
constexpr bool g_HistogramValueTypeHavePlus ()
 
 CHistogram< TValue, TScale, TCounter >::CHistogram (TValue min_value, TValue max_value, unsigned n_bins, EScaleType scale_type=eLinear, EScaleView scale_view=eMonotonic)
 Constructor. More...
 
void CHistogram< TValue, TScale, TCounter >::AddLeftScale (TValue min_value, unsigned n_bins, EScaleType scale_type)
 Add auxiliary left/right scales. More...
 
void CHistogram< TValue, TScale, TCounter >::AddRightScale (TValue max_value, unsigned n_bins, EScaleType scale_type)
 
template<typename V , typename S = TSum, std::enable_if_t< g_HistogramValueTypeHavePlus< S >(), int > = 0>
void CHistogram< TValue, TScale, TCounter >::Add (const V &v)
 Add value to the data distribution. More...
 
TSum CHistogram< TValue, TScale, TCounter >::GetSum (void) const
 Return the sum of all added values. More...
 
void CHistogram< TValue, TScale, TCounter >::Reset ()
 Reset all data counters. More...
 
void CHistogram< TValue, TScale, TCounter >::AddCountersFrom (const CHistogram &other)
 Add counters from 'other' histogram to this histogram, 'other' doesn't changes. More...
 
void CHistogram< TValue, TScale, TCounter >::StealCountersFrom (CHistogram &other)
 Add counters from 'other' histogram to this histogram, then reset the counters of 'other' histogram. More...
 
TValue CHistogram< TValue, TScale, TCounter >::GetMin () const
 Get the lower bound of the combined scale. More...
 
TValue CHistogram< TValue, TScale, TCounter >::GetMax () const
 Get the upper bound of the combined scale. More...
 
unsigned CHistogram< TValue, TScale, TCounter >::GetNumberOfBins () const
 Return the number ot bins on the combined scale. More...
 
void CHistogram< TValue, TScale, TCounter >::GetBinStarts (vector< TScale > &positions)
 Get starting positions for bins on the combined scale. More...
 
const TScale * CHistogram< TValue, TScale, TCounter >::GetBinStartsPtr () const
 Get starting positions for bins on the combined scale (not MT safe). More...
 
void CHistogram< TValue, TScale, TCounter >::GetBinCounters (vector< TCounter > &counters)
 Get counters for the combined scale's bins. More...
 
const TCounter * CHistogram< TValue, TScale, TCounter >::GetBinCountersPtr () const
 Get counters for the combined scale's bins (not MT safe). More...
 
TCounter CHistogram< TValue, TScale, TCounter >::GetCount () const
 Get total number of hits whose value fell between GetMin() and GetMax(). More...
 
size_t CHistogram< TValue, TScale, TCounter >::GetLowerAnomalyCount () const
 Get number of hits whose values were less than GetMin(). More...
 
size_t CHistogram< TValue, TScale, TCounter >::GetUpperAnomalyCount () const
 Get number of hits whose values were greater than GetMax(). More...
 
static unsigned CHistogram< TValue, TScale, TCounter >::EstimateNumberOfBins (size_t n, EEstimateNumberOfBinsRule rule=0)
 Estimate numbers of bins on the base of the expected number of observations 'n'. More...
 
 CHistogram< TValue, TScale, TCounter >::CHistogram (void)
 Default constructor. More...
 
 CHistogram< TValue, TScale, TCounter >::CHistogram (CHistogram &&other)
 
CHistogramCHistogram< TValue, TScale, TCounter >::operator= (CHistogram &&other)
 
CHistogram CHistogram< TValue, TScale, TCounter >::Clone (EClone how=eCloneAll) const
 Clone histogram structure. More...
 
void CHistogram< TValue, TScale, TCounter >::EnableMT (void)
 Add MT protection to histogram. More...
 
void CHistogram< TValue, TScale, TCounter >::MT_Lock () const
 MT locking. More...
 
void CHistogram< TValue, TScale, TCounter >::MT_Unlock () const
 
void CHistogram< TValue, TScale, TCounter >::x_CalculateBins (TScale start_value, TScale end_value, unsigned pos, unsigned n, EScaleType scale_type, EScaleView scale_view)
 Calculate bins starting positions. More...
 
void CHistogram< TValue, TScale, TCounter >::x_CalculateBinsLinear (TScale start_value, TScale end_value, TScale step, TScale *arr, unsigned pos, unsigned n, EScaleView scale_view)
 Calculate bins starting positions for a linear scale. More...
 
void CHistogram< TValue, TScale, TCounter >::x_CalculateBinsLog (TScale start_value, TScale end_value, TScale *arr, unsigned pos, unsigned n, EScaleType scale_type, EScaleView scale_view)
 Calculate bins starting positions for a logarithmic scale. More...
 
TScale CHistogram< TValue, TScale, TCounter >::x_Func (EScaleType scale_type, TScale value)
 Scale function. More...
 
TScale CHistogram< TValue, TScale, TCounter >::x_FuncInverse (EScaleType scale_type, TScale scale_value)
 Inverse scale function. More...
 
void CHistogram< TValue, TScale, TCounter >::x_Add (TValue value)
 Add value to the data distribution (internal version without locking). More...
 
void CHistogram< TValue, TScale, TCounter >::x_AddLinear (TValue value)
 Add value to the data distribution using a linear search method. More...
 
void CHistogram< TValue, TScale, TCounter >::x_AddBisection (TValue value)
 Add value to the data distribution using a bisection search method. More...
 
void CHistogram< TValue, TScale, TCounter >::x_MoveFrom (CHistogram &other)
 Move data from 'other' histogram. 'other' became invalid. More...
 
void CHistogram< TValue, TScale, TCounter >::x_AddCountersFrom (CHistogram &other)
 Add counters from 'other' histogram. More...
 
bool CHistogram< TValue, TScale, TCounter >::x_IsEqual (TScale a, TScale b)
 Check that 'a' and 'b' scale values are equal (or almost equal for floating scales). More...
 
void CHistogram< TValue, TScale, TCounter >::x_Reset ()
 Reset all data counters (internal version without locking). More...
 
 CHistogram< TValue, TScale, TCounter >::CHistogram (const CHistogram &)
 Prevent copying. More...
 
CHistogramCHistogram< TValue, TScale, TCounter >::operator= (const CHistogram &)
 
 CHistogramTimeSeries< TValue, TScale, TCounter >::CHistogramTimeSeries (THistogram &model_histogram)
 
void CHistogramTimeSeries< TValue, TScale, TCounter >::Add (TValue value)
 Add value to the data distribution. More...
 
void CHistogramTimeSeries< TValue, TScale, TCounter >::Rotate ()
 Merge the most recent (now active) histogram data into the time series. More...
 
void CHistogramTimeSeries< TValue, TScale, TCounter >::Reset ()
 Reset to the initial state. More...
 
 CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::STimeBin (const STimeBin &other)
 
STimeBinCHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::operator= (const STimeBin &other)
 
 CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::STimeBin (THistogram &&h, TTicks t)
 
TTimeBins CHistogramTimeSeries< TValue, TScale, TCounter >::GetHistograms () const
 Histograms – in the order from the most recent to the least recent. More...
 
TTicks CHistogramTimeSeries< TValue, TScale, TCounter >::GetCurrentTick (void) const
 Number of ticks the histogram series has handled. More...
 
void CHistogramTimeSeries< TValue, TScale, TCounter >::x_AppendBin (const THistogram &model_histogram, TTicks n_ticks)
 
void CHistogramTimeSeries< TValue, TScale, TCounter >::x_Shift (size_t index, typename TTimeBins::iterator current_it)
 

Variables

TValue CHistogram< TValue, TScale, TCounter >::m_Min
 Minimum value (the lower bound of combined scale) More...
 
TValue CHistogram< TValue, TScale, TCounter >::m_Max
 Maximum value (the upper bound of combined scale) More...
 
unsigned CHistogram< TValue, TScale, TCounter >::m_NumBins
 Number of bins (m_Starts[]/m_Counts[] length) More...
 
TSum CHistogram< TValue, TScale, TCounter >::m_Sum = {}
 Sum of the all added values (if applicable for TValue) More...
 
std::unique_ptr< TScale[]> CHistogram< TValue, TScale, TCounter >::m_Starts
 Combined scale: starting bins positions. More...
 
std::unique_ptr< TCounter[]> CHistogram< TValue, TScale, TCounter >::m_Counters
 Combined scale: counters - the number of measurements for each bin. More...
 
TCounter CHistogram< TValue, TScale, TCounter >::m_Count
 Number of counted values (sum all m_Counters[]) More...
 
TCounter CHistogram< TValue, TScale, TCounter >::m_LowerAnomalyCount
 Number of anomaly values < m_Min. More...
 
TCounter CHistogram< TValue, TScale, TCounter >::m_UpperAnomalyCount
 Number of anomaly values > m_Max. More...
 
bool CHistogram< TValue, TScale, TCounter >::m_IsMT
 MT protection flag. More...
 
std::mutex CHistogram< TValue, TScale, TCounter >::m_Mutex
 MT protection mutex. More...
 
THistogram CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::histogram
 Histogram for the ticks. More...
 
TTicks CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::n_ticks
 Number of ticks in this histogram. More...
 
TTimeBins CHistogramTimeSeries< TValue, TScale, TCounter >::m_TimeBins
 
std::mutex CHistogramTimeSeries< TValue, TScale, TCounter >::m_Mutex
 
TTicks CHistogramTimeSeries< TValue, TScale, TCounter >::m_CurrentTick
 

Detailed Description

Macro Definition Documentation

◆ RETURN_MT_SAFE

#define RETURN_MT_SAFE (   member)
Value:
if (m_IsMT) { \
MT_Lock(); \
auto v = member; \
MT_Unlock(); \
return v; \
} \
return member
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 228 of file data_histogram.hpp.

Typedef Documentation

◆ T_HistogramValueTypeHavePlus

template<typename T >
using T_HistogramValueTypeHavePlus = decltype((T&)(std::declval<T>().operator+=(std::declval<const T&>())))

Helper types for CHistogram<>::GetSum() support.

Definition at line 65 of file data_histogram.hpp.

◆ TArithmetic

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
using CHistogram< TValue, TScale, TCounter >::TArithmetic = typename std::conditional<std::is_floating_point<TValue>::value, double, TIntegral>::type

◆ THistogram

template<typename TValue , typename TScale , typename TCounter >
using CHistogramTimeSeries< TValue, TScale, TCounter >::THistogram = CHistogram<TValue,TScale,TCounter>
Parameters
model_histogramThis histogram will be used as a template for all histogram objects in this time series.
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 548 of file data_histogram.hpp.

◆ TIntegral

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
using CHistogram< TValue, TScale, TCounter >::TIntegral = typename std::conditional<std::numeric_limits <TValue>::is_signed, int64_t, uint64_t >::type

Sum type: double for all floating points TValue types, int64_t/uint64_t for integral, and TValue otherwise.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 201 of file data_histogram.hpp.

◆ TSum

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
using CHistogram< TValue, TScale, TCounter >::TSum = typename std::conditional<std::is_arithmetic <TValue>::value, TArithmetic, TValue >::type

◆ TTicks

template<typename TValue , typename TScale , typename TCounter >
using CHistogramTimeSeries< TValue, TScale, TCounter >::TTicks = unsigned int

Type of the unit of time.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 565 of file data_histogram.hpp.

◆ TTimeBins

template<typename TValue , typename TScale , typename TCounter >
using CHistogramTimeSeries< TValue, TScale, TCounter >::TTimeBins = list<STimeBin>

Type of the series of histograms.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 590 of file data_histogram.hpp.

Enumeration Type Documentation

◆ EClone

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
enum CHistogram::EClone
Enumerator
eCloneAll 

Clone whole histogram, with scale and counters.

eCloneStructureOnly 

Clone structure only (the counters will be zeroed)

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 417 of file data_histogram.hpp.

◆ EEstimateNumberOfBinsRule

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
enum CHistogram::EEstimateNumberOfBinsRule

Rules to calculate an estimated numbers of bins on the base of the expected number of observations.

Note, that there is no "best" number of bins, and different bin sizes can reveal different features of the data. All these methods generally make strong assumptions about the shape of the distribution. Depending on the actual data distribution and the goals of the analysis, different bin widths may be appropriate, so experimentation is usually needed to determine an appropriate width.

Note
All methods applies to the linear scale only, that have a fixed bin sizes.
See also
EstimateNumberOfBins
Enumerator
eSquareRoot 

Square root rule.

Used by Excel histograms and many others. Default value for EstimateNumberOfBins() as well.

eJuran 

Juran's "Quality Control Handbook" that provide guidelines to select the number of bins for histograms.

eSturge 

Herbert Sturge's rule.

It works best for continuous data that is normally distributed and symmetrical. As long as your data is not skewed, using Sturge's rule should give you a nice-looking, easy to read histogram that represents the data well.

eRice 

Rice's rule. Presented as a simple alternative to Sturge's rule.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 361 of file data_histogram.hpp.

◆ EScaleType

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
enum CHistogram::EScaleType

Scale type.

Most common is a linear scale, where each bin have the same size. It is good if you have a limited range, but sometimes values are distributed very wide, and if you want to count all of them, but concentrate on a some range with most significant values, logarithmic scales helps a lot. For logarithmic scales each next bin have a greater size. Bins size increasing depends on a logarithmic base (used scale type).

Enumerator
eLinear 

Arithmetic or linear scale.

eLog 

Natural logarithmic scale with a base e ~ 2.72.

eLog2 

Binary logarithmic scale with a base 2.

eLog10 

Common logarithmic scale with a base 10.

Definition at line 125 of file data_histogram.hpp.

◆ EScaleView

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
enum CHistogram::EScaleView

Methods to build bins for a specified scale.

Applies to the main scale, defined in constructor, only.

Enumerator
eMonotonic 

Use specified scale method to calculate bins sizes from a minimum to a maximum value.

eSymmetrical 

Determine a mean for a specified value range and calculates bins sizes using specified scale to both sides from it, symmetrically.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 134 of file data_histogram.hpp.

Function Documentation

◆ Add() [1/2]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
template<typename V , typename S = TSum, std::enable_if_t< g_HistogramValueTypeHavePlus< S >(), int > = 0>
void CHistogram< TValue, TScale, TCounter >::Add ( const V &  v)
inline

Add value to the data distribution.

Try to find an appropriate bin for a specified value and increase its counter on 1. Also, calculates a sum of all added values if TValue type have addition support.

See also
GetStarts, GetCounters, GetSum
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 212 of file data_histogram.hpp.

◆ Add() [2/2]

template<typename TValue , typename TScale , typename TCounter >
void CHistogramTimeSeries< TValue, TScale, TCounter >::Add ( TValue  value)

Add value to the data distribution.

Try to find an appropriate bin for a specified value and increment its counter by 1.

See also
CHistogram::Add()
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 1283 of file data_histogram.hpp.

References rapidjson::value.

◆ AddCountersFrom()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::AddCountersFrom ( const CHistogram< TValue, TScale, TCounter > &  other)

Add counters from 'other' histogram to this histogram, 'other' doesn't changes.

Note
Both histograms should have the same structure.
See also
Clone, Reset, StealCountersFrom
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Referenced by CPSGTimingBase::SerializeCombined().

◆ AddLeftScale()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::AddLeftScale ( TValue  min_value,
unsigned  n_bins,
EScaleType  scale_type 
)

Add auxiliary left/right scales.

The CHistogram constructor defines a main scale for some data range. It can be very limited to get more precise results for the value distribution. You can get the number of hits whose values fall outside the range of the main scale using GetLowerAnomalyCount()/GetUpperAnomalyCount() methods, but each returns a single number of hits outside of the range. The other method is to use auxiliary scale(s) to count the number of hits for the less significant range(s). You can add any number of scales from each side. So, you can use linear scale with much greater bin sizes, or logarithmic scales, that allow to cover a very wide range of data with a limited number of bins. See EScaleType for details.

Parameters
min_valueMinimum allowed value for the auxiliary scale. Its maximum value is the same as a minimum value for the main scale, or previously added scale.
n_binsNumber of bins for the auxiliary scale.
scale_typePredefined scale type. Corresponding scale function will be used to calculate scale's bin ranges.
Note
It is not allowed to add left/right auxiliary scales after starting counting hits. Please use these methods before Add(), or after Reset().
See also
CHistogram::CHistogram, AddRightScale, EScaleType, GetLowerAnomalyCount, GetUpperAnomalyCount
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ AddRightScale()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::AddRightScale ( TValue  max_value,
unsigned  n_bins,
EScaleType  scale_type 
)

◆ CHistogram() [1/4]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
CHistogram< TValue, TScale, TCounter >::CHistogram ( CHistogram< TValue, TScale, TCounter > &&  other)

◆ CHistogram() [2/4]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
CHistogram< TValue, TScale, TCounter >::CHistogram ( const CHistogram< TValue, TScale, TCounter > &  )
protected

Prevent copying.

See move constructor and move assignment operator to use with move-semantics.

◆ CHistogram() [3/4]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
CHistogram< TValue, TScale, TCounter >::CHistogram ( TValue  min_value,
TValue  max_value,
unsigned  n_bins,
EScaleType  scale_type = eLinear,
EScaleView  scale_view = eMonotonic 
)

Constructor.

Parameters
min_valueMinimum allowed value in range [min_value, max_value].
max_valueMaximum allowed value in range [min_value, max_value].
n_binsNumber of bins for the histogram (main scale).
scale_typePredefined scale type. Corresponding scale function will be used to calculate scale's bin ranges.
scale_viewScale view (symmetrical or monotonic).
See also
EScaleType, EScaleView, AddLeftScale, AddRightScale, Add

◆ CHistogram() [4/4]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
CHistogram< TValue, TScale, TCounter >::CHistogram ( void  )

Default constructor.

Creates empty object. The object itself is invalid without min/max values, and any scale. Should be used with conjunction of Clone() only.

See also
Clone
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ CHistogramTimeSeries()

template<typename TValue , typename TScale , typename TCounter >
CHistogramTimeSeries< TValue, TScale, TCounter >::CHistogramTimeSeries ( THistogram model_histogram)

◆ Clone()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
CHistogram CHistogram< TValue, TScale, TCounter >::Clone ( EClone  how = eCloneAll) const

Clone histogram structure.

Creates a copy of the histogram structure depending on clone method. By default it is a whole copy, but you can clone histogram's structure only, without counters.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Referenced by CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::operator=(), CPSGTimingBase::SerializeCombined(), and CHistogramTimeSeries< TValue, TScale, TCounter >::x_AppendBin().

◆ EnableMT()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::EnableMT ( void  )
inline

Add MT protection to histogram.

By default CHistogram is not MT protected and intended to be created and used withing the same thread. Calling this method add MT protection on adding additional scales, adding and resetting values, cloning and moving histograms. Please call this method immediately after creating each histogram, before accessing it from any other thread, or deadlock can occurs.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 441 of file data_histogram.hpp.

◆ EstimateNumberOfBins()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
static unsigned CHistogram< TValue, TScale, TCounter >::EstimateNumberOfBins ( size_t  n,
EEstimateNumberOfBinsRule  rule = 0 
)
static

Estimate numbers of bins on the base of the expected number of observations 'n'.

Note
Applies to the linear scale only.
See also
EEstimateNumberOfBinsRules
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ g_HistogramValueTypeHavePlus()

template<typename T >
constexpr bool g_HistogramValueTypeHavePlus ( )
constexpr

◆ GetBinCounters()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::GetBinCounters ( vector< TCounter > &  counters)
inline

Get counters for the combined scale's bins.

Populate a vector with counters for the combined scale's bins. The size of the vector changes to be equal to the number of bins.

See also
GetNumberOfBins, GetBinStarts, GetBinCountersPtr, Add
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 314 of file data_histogram.hpp.

◆ GetBinCountersPtr()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
const TCounter* CHistogram< TValue, TScale, TCounter >::GetBinCountersPtr ( ) const
inline

Get counters for the combined scale's bins (not MT safe).

Returns a pointer to array. The number of bins can be obtained with GetNumberOfBins().

Warning
Be aware that any change in the histogram's structure invalidate all data and pointer itself. This method is not intended to use in MT environment. Please use vector version GetBinCounters(vector<TCounter>&).
See also
GetNumberOfBins, GetBinStartsPtr, GetBinCounters, Add, EnableMT
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 329 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ GetBinStarts()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::GetBinStarts ( vector< TScale > &  positions)
inline

Get starting positions for bins on the combined scale.

Populate a vector with starting positions for bins on the combined scale. The size of the vector changes to be equal the number of bins.

See also
GetNumberOfBins, GetBinCounters, GetBinStartsPtr
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 287 of file data_histogram.hpp.

◆ GetBinStartsPtr()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
const TScale* CHistogram< TValue, TScale, TCounter >::GetBinStartsPtr ( ) const
inline

Get starting positions for bins on the combined scale (not MT safe).

Returns a pointer to array. The number of bins can be obtained with GetNumberOfBins(). and a number of a counters in each bin – with GetBinCounters().

Warning
Be aware that any change in the histogram's structure, adding additional scales, invalidate all data and pointer itself. This method is not intended to use in MT environment. Please use vector version GetBinStarts(vector<TScale>&).
See also
GetNumberOfBins, GetBinCountersPtr, GetBinStarts, EnableMT
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 303 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ GetCount()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TCounter CHistogram< TValue, TScale, TCounter >::GetCount ( void  ) const
inline

Get total number of hits whose value fell between GetMin() and GetMax().

The number of hits whose values fall outside that range can be obtained using GetLowerAnomalyCount() and GetUpperAnomalyCount() methods.

See also
GetMin, GetMax, GetLowerAnomalyCount, GetUpperAnomalyCount, GetBinCounters
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 335 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ GetCurrentTick()

template<typename TValue , typename TScale , typename TCounter >
TTicks CHistogramTimeSeries< TValue, TScale, TCounter >::GetCurrentTick ( void  ) const
inline

Number of ticks the histogram series has handled.

Initially the number of ticks is zero.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 597 of file data_histogram.hpp.

References CHistogramTimeSeries< TValue, TScale, TCounter >::m_CurrentTick.

◆ GetHistograms()

template<typename TValue , typename TScale , typename TCounter >
CHistogramTimeSeries< TValue, TScale, TCounter >::TTimeBins CHistogramTimeSeries< TValue, TScale, TCounter >::GetHistograms

Histograms – in the order from the most recent to the least recent.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 1359 of file data_histogram.hpp.

◆ GetLowerAnomalyCount()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
size_t CHistogram< TValue, TScale, TCounter >::GetLowerAnomalyCount ( ) const
inline

Get number of hits whose values were less than GetMin().

See also
GetUpperAnomalyCount, GetCount
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 339 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ GetMax()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TValue CHistogram< TValue, TScale, TCounter >::GetMax ( void  ) const
inline

Get the upper bound of the combined scale.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 276 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ GetMin()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TValue CHistogram< TValue, TScale, TCounter >::GetMin ( void  ) const
inline

Get the lower bound of the combined scale.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 273 of file data_histogram.hpp.

◆ GetNumberOfBins()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
unsigned CHistogram< TValue, TScale, TCounter >::GetNumberOfBins ( ) const
inline

Return the number ot bins on the combined scale.

See also
GetBinStarts, GetBinCounters, GetBinCountersPtr
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 280 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ GetSum()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TSum CHistogram< TValue, TScale, TCounter >::GetSum ( void  ) const
inline

Return the sum of all added values.

Returns
Returned type depends on TValue type, and converts to:
  • double – for all floating point types;
  • int64_t – signed integral types;
  • uint64_t – unsigned integral types;
  • TValue – for all other types. The sum can be calculated for floating, integral types and all other TValue types that have 'operator +=' defined. If TValue type doesn't have such operator defined, empty value {} is returned. Note, compiler can convert this empty {} value to TScale type, because every TValue should have 'operator TScale() const' by design.
Note
This method doesn't check calculated sum on overflow.
See also
Add, TSum
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 252 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ GetUpperAnomalyCount()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
size_t CHistogram< TValue, TScale, TCounter >::GetUpperAnomalyCount ( ) const
inline

Get number of hits whose values were greater than GetMax().

See also
GetLowerAnomalyCount, GetCount
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 343 of file data_histogram.hpp.

Referenced by SerializeHistogram().

◆ MT_Lock()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::MT_Lock ( ) const
inline

◆ MT_Unlock()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::MT_Unlock ( ) const
inline

◆ operator=() [1/3]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
CHistogram& CHistogram< TValue, TScale, TCounter >::operator= ( CHistogram< TValue, TScale, TCounter > &&  other)

◆ operator=() [2/3]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
CHistogram& CHistogram< TValue, TScale, TCounter >::operator= ( const CHistogram< TValue, TScale, TCounter > &  )
protected

◆ operator=() [3/3]

template<typename TValue , typename TScale , typename TCounter >
STimeBin& CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::operator= ( const STimeBin other)
inline

◆ Reset() [1/2]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::Reset ( )

◆ Reset() [2/2]

template<typename TValue , typename TScale , typename TCounter >
void CHistogramTimeSeries< TValue, TScale, TCounter >::Reset ( void  )

Reset to the initial state.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 1304 of file data_histogram.hpp.

◆ Rotate()

template<typename TValue , typename TScale , typename TCounter >
void CHistogramTimeSeries< TValue, TScale, TCounter >::Rotate

Merge the most recent (now active) histogram data into the time series.

This method is generally supposed to be called periodically, thus defining the unit of time (tick) as far as this API is concerned.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 1292 of file data_histogram.hpp.

◆ StealCountersFrom()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::StealCountersFrom ( CHistogram< TValue, TScale, TCounter > &  other)

Add counters from 'other' histogram to this histogram, then reset the counters of 'other' histogram.

Note
Both histograms should have the same structure.
See also
Clone, Reset, AddCountersFrom
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ STimeBin() [1/2]

template<typename TValue , typename TScale , typename TCounter >
CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::STimeBin ( const STimeBin other)
inline

◆ STimeBin() [2/2]

template<typename TValue , typename TScale , typename TCounter >
CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::STimeBin ( THistogram &&  h,
TTicks  t 
)
inline

Definition at line 582 of file data_histogram.hpp.

◆ x_Add()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_Add ( TValue  value)
protected

Add value to the data distribution (internal version without locking).

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Referenced by CHistogram< TValue, TScale, TCounter >::Add().

◆ x_AddBisection()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_AddBisection ( TValue  value)
protected

Add value to the data distribution using a bisection search method.

Usually faster on a long scales with a lot of bins.

See also
Add, x_AddLinear
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_AddCountersFrom()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_AddCountersFrom ( CHistogram< TValue, TScale, TCounter > &  other)
protected

Add counters from 'other' histogram.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_AddLinear()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_AddLinear ( TValue  value)
protected

Add value to the data distribution using a linear search method.

Usually faster than bisection method on a small number of bins, or if the values have a tendency to fall into the starting bins for a used scale.

See also
Add, x_AddBisection
Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_AppendBin()

template<typename TValue , typename TScale , typename TCounter >
void CHistogramTimeSeries< TValue, TScale, TCounter >::x_AppendBin ( const THistogram model_histogram,
TTicks  n_ticks 
)
private

◆ x_CalculateBins()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_CalculateBins ( TScale  start_value,
TScale  end_value,
unsigned  pos,
unsigned  n,
EScaleType  scale_type,
EScaleView  scale_view 
)
protected

Calculate bins starting positions.

Calculate positions for 'n' number of bins in [start,end] value range, starting from 'pos' bin index. If start_value > end_value, calculating going from the right to left. This is applicable for symmetrical scales, or multi-scales, with left scale added.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_CalculateBinsLinear()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_CalculateBinsLinear ( TScale  start_value,
TScale  end_value,
TScale  step,
TScale *  arr,
unsigned  pos,
unsigned  n,
EScaleView  scale_view 
)
protected

Calculate bins starting positions for a linear scale.

Account for an integer TScale type and calculation truncation.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_CalculateBinsLog()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_CalculateBinsLog ( TScale  start_value,
TScale  end_value,
TScale *  arr,
unsigned  pos,
unsigned  n,
EScaleType  scale_type,
EScaleView  scale_view 
)
protected

Calculate bins starting positions for a logarithmic scale.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_Func()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TScale CHistogram< TValue, TScale, TCounter >::x_Func ( EScaleType  scale_type,
TScale  value 
)
protected

Scale function.

Calculates scale position on a base of data value.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_FuncInverse()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TScale CHistogram< TValue, TScale, TCounter >::x_FuncInverse ( EScaleType  scale_type,
TScale  scale_value 
)
protected

Inverse scale function.

Calculates a data value on a base of scale value/position.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_IsEqual()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
bool CHistogram< TValue, TScale, TCounter >::x_IsEqual ( TScale  a,
TScale  b 
)
protected

Check that 'a' and 'b' scale values are equal (or almost equal for floating scales).

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_MoveFrom()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_MoveFrom ( CHistogram< TValue, TScale, TCounter > &  other)
protected

Move data from 'other' histogram. 'other' became invalid.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_Reset()

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
void CHistogram< TValue, TScale, TCounter >::x_Reset ( )
protected

Reset all data counters (internal version without locking).

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

◆ x_Shift()

template<typename TValue , typename TScale , typename TCounter >
void CHistogramTimeSeries< TValue, TScale, TCounter >::x_Shift ( size_t  index,
typename TTimeBins::iterator  current_it 
)
private

Variable Documentation

◆ histogram

template<typename TValue , typename TScale , typename TCounter >
THistogram CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::histogram

◆ m_Count

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TCounter CHistogram< TValue, TScale, TCounter >::m_Count
protected

Number of counted values (sum all m_Counters[])

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 528 of file data_histogram.hpp.

Referenced by CHistogram< TValue, TScale, TCounter >::GetCount().

◆ m_Counters

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
std::unique_ptr<TCounter[]> CHistogram< TValue, TScale, TCounter >::m_Counters
protected

Combined scale: counters - the number of measurements for each bin.

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 526 of file data_histogram.hpp.

Referenced by CHistogram< TValue, TScale, TCounter >::GetBinCounters(), and CHistogram< TValue, TScale, TCounter >::GetBinCountersPtr().

◆ m_CurrentTick

template<typename TValue , typename TScale , typename TCounter >
TTicks CHistogramTimeSeries< TValue, TScale, TCounter >::m_CurrentTick
private

◆ m_IsMT

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
bool CHistogram< TValue, TScale, TCounter >::m_IsMT
protected

◆ m_LowerAnomalyCount

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TCounter CHistogram< TValue, TScale, TCounter >::m_LowerAnomalyCount
protected

◆ m_Max

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TValue CHistogram< TValue, TScale, TCounter >::m_Max
protected

Maximum value (the upper bound of combined scale)

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 521 of file data_histogram.hpp.

Referenced by CHistogram< TValue, TScale, TCounter >::GetMax().

◆ m_Min

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TValue CHistogram< TValue, TScale, TCounter >::m_Min
protected

Minimum value (the lower bound of combined scale)

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 520 of file data_histogram.hpp.

Referenced by CHistogram< TValue, TScale, TCounter >::GetMin().

◆ m_Mutex [1/2]

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
std::mutex CHistogram< TValue, TScale, TCounter >::m_Mutex
mutableprotected

◆ m_Mutex [2/2]

template<typename TValue , typename TScale , typename TCounter >
std::mutex CHistogramTimeSeries< TValue, TScale, TCounter >::m_Mutex
mutableprivate

◆ m_NumBins

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
unsigned CHistogram< TValue, TScale, TCounter >::m_NumBins
protected

◆ m_Starts

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
std::unique_ptr<TScale[]> CHistogram< TValue, TScale, TCounter >::m_Starts
protected

◆ m_Sum

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TSum CHistogram< TValue, TScale, TCounter >::m_Sum = {}
protected

Sum of the all added values (if applicable for TValue)

Examples
/home/coremake/doxygen/cxx/include/util/data_histogram.hpp.

Definition at line 523 of file data_histogram.hpp.

Referenced by CHistogram< TValue, TScale, TCounter >::Add(), and CHistogram< TValue, TScale, TCounter >::GetSum().

◆ m_TimeBins

template<typename TValue , typename TScale , typename TCounter >
TTimeBins CHistogramTimeSeries< TValue, TScale, TCounter >::m_TimeBins
private

◆ m_UpperAnomalyCount

template<typename TValue = int, typename TScale = TValue, typename TCounter = Uint8>
TCounter CHistogram< TValue, TScale, TCounter >::m_UpperAnomalyCount
protected

◆ n_ticks

template<typename TValue , typename TScale , typename TCounter >
TTicks CHistogramTimeSeries< TValue, TScale, TCounter >::STimeBin::n_ticks
Modified on Sun Apr 14 05:28:14 2024 by modify_doxy.py rev. 669887