SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Friends
Histogram Class Reference

Constructs and maintains a histogram of input data. More...

#include <rw/histo.h>

Inheritance diagram for Histogram:
RWMathVec< int > RWVecView RWDataView

Public Member Functions

 Histogram ()
 
 Histogram (size_t nbins, const RWMathVec< double > &v)
 
 Histogram (const RWMathVec< double > &b)
 
 Histogram (size_t nbins, double min, double max)
 
 Histogram (const Histogram &)
 
void addCount (double a)
 
void addCount (const RWMathVec< double > &v)
 
RWMathVec< double > binBoundaries () const
 
size_t bins () const
 
size_t larger () const
 
Histogramoperator= (const Histogram &h)
 
HistogramresetCounts ()
 
size_t smaller () const
 
size_t totalCount () const
 
- Public Member Functions inherited from RWMathVec< int >
 RWMathVec (size_t n, RWRandInterface &r)
 
 RWMathVec ()
 
 RWMathVec (const RWMathVec< int > &a)
 
 RWMathVec (size_t n, RWUninitialized)
 
 RWMathVec (size_t n, const int &initval)
 
 RWMathVec (size_t n, const int &initval, const int &incr)
 
 RWMathVec (const char *s)
 
 RWMathVec (const RWMathVecPick< int > &p)
 
 RWMathVec (const int *dat, size_t n)
 
 RWMathVec (const RWMathVec< double > &re, const RWMathVec< double > &im)
 
RWMathVec< int > apply (typename rw_numeric_traits< int >::mathFunType f) const
 
RWMathVec< norm_typeapply2 (mathFunType2 f) const
 
iterator begin ()
 
const_iterator begin () const
 
size_t binaryStoreSize () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
RWMathVec< int > copy () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
int * data ()
 
const int * data () const
 
RWMathVec< int > deepCopy () const
 
void deepenShallowCopy ()
 
iterator end ()
 
const_iterator end () const
 
size_t length () const
 
 operator RWMathVec< promote_type > ()
 
bool operator!= (const RWMathVec< int > &v) const
 
int & operator() (int i)
 
int operator() (int i) const
 
RWMathVec< int > operator() (const RWSlice &)
 
const RWMathVec< int > operator() (const RWSlice &) const
 
RWMathVec< int > & operator*= (const int &v)
 
RWMathVec< int > & operator*= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator++ ()
 
void operator++ (int)
 
RWMathVec< int > & operator+= (const int &v)
 
RWMathVec< int > & operator+= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator-- ()
 
void operator-- (int)
 
RWMathVec< int > & operator-= (const int &v)
 
RWMathVec< int > & operator-= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator/= (const int &v)
 
RWMathVec< int > & operator/= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator= (const RWMathVecPick< int > &v)
 
RWMathVec< int > & operator= (const int &v)
 
bool operator== (const RWMathVec< int > &) const
 
int & operator[] (int i)
 
int operator[] (int i) const
 
RWMathVec< int > operator[] (const RWSlice &)
 
const RWMathVec< int > operator[] (const RWSlice &) const
 
RWMathVecPick< int > pick (const RWIntVec &v)
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
RWMathVec< int > & reference (const RWMathVec< int > &v)
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
void reshape (size_t n)
 
void resize (size_t n)
 
void restoreFrom (RWFile &)
 
void restoreFrom (RWvistream &)
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) const
 
RWMathVec< int > slice (int start, size_t n, int stride=1) const
 
int stride () const
 
- Public Member Functions inherited from RWVecView
size_t length () const
 
int stride () const
 

Friends

std::ostream & operator<< (std::ostream &s, const Histogram &h)
 

Additional Inherited Members

- Public Types inherited from RWMathVec< int >
typedef RWMathVecConstIterator< int > const_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef RWMathVecIterator< int > iterator
 
typedef rw_numeric_traits< int >::mathFunType mathFunType
 
typedef rw_numeric_traits< int >::mathFunType2 mathFunType2
 
typedef rw_numeric_traits< int >::norm_type norm_type
 
typedef rw_numeric_traits< int >::promote_type promote_type
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
- Public Types inherited from RWDataView
enum  Storage { COLUMN_MAJOR, ROW_MAJOR, RWEITHER }
 

Detailed Description

The class Histogram constructs and maintains a histogram of input data. The count is stored as a public RWMathVec<int> base class. It can be used anywhere an RWMathVec<int> can be used.

Synopsis
#include <rw/histo.h>
#include <rw/math/mathvec.h>
unsigned n;
Histogram H(n, v);

Constructor & Destructor Documentation

Histogram::Histogram ( )

Constructs a histogram with 0 bins.

Histogram::Histogram ( size_t  nbins,
const RWMathVec< double > &  v 
)

Constructs a histogram from the data in v, with nbins bins of data. The bins are of equal size and are scaled with the maximum and minimum data in v. The count in the histogram is initialized with the contents of v.

Histogram::Histogram ( const RWMathVec< double > &  b)

Constructs a histogram with no initial data, with bin boundaries defined by the data in b. The number of bins is b.length()-1.

Histogram::Histogram ( size_t  nbins,
double  min,
double  max 
)

Constructs a histogram with no initial data, with nbins bins. The bins are of equal size and are scaled with max and min.

Histogram::Histogram ( const Histogram )

Copy constructor. The new histogram does not reference the old histogram's data.

Member Function Documentation

void Histogram::addCount ( double  a)

Adds data value a to the histogram.

void Histogram::addCount ( const RWMathVec< double > &  v)

Adds the contents of the vector v to the histogram.

RWMathVec<double> Histogram::binBoundaries ( ) const
inline

Returns the boundaries of the histogram's bins as a vector.

size_t Histogram::bins ( ) const
inline

Returns the number of bins.

size_t Histogram::larger ( ) const
inline

Returns the total accumulated number of data values that are greater than the largest bin.

Histogram& Histogram::operator= ( const Histogram h)

Assignment operator. Self is a copy of the data in h.

Histogram& Histogram::resetCounts ( )

Removes all data values from the histogram. Each bin count, including larger and smaller counts, is set to 0. The bin boundaries are retained. Returns a reference to self.

size_t Histogram::smaller ( ) const
inline

Returns the total accumulated number of data values that are less than the smallest bin.

size_t Histogram::totalCount ( ) const
inline

Returns the total accumulated number of data values in the histogram. This the sum of all the bin counts, plus the number of data values that are smaller than the smallest bin, and the number of data values that are larger than the largest bin.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const Histogram h 
)
friend

Outputs a summary of the histogram h on std::ostream s.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.