Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Related Functions
bsta_histogram< T > Class Template Reference

#include <bsta_histogram.h>

Inheritance diagram for bsta_histogram< T >:
Inheritance graph
[legend]

List of all members.

Public Types

enum  bsta_hist_type { HIST_TYPE_UNKNOWN = 0, HIST_TYPE_FLOAT = 1, HIST_TYPE_DOUBLE = 2, HIST_TYPE_END = 3 }

Public Member Functions

 bsta_histogram ()
 Default constructor.
 bsta_histogram (const T range, const unsigned int nbins, const T min_prob=0.0)
 Simple constructor that assumes all data values are positive.
 bsta_histogram (const T min, const T max, const unsigned int nbins, const T min_prob=0.0)
 More general constructor defining a signed value range.
 bsta_histogram (const unsigned int nbins, const T min, const T delta, const T min_prob=0.0)
 More general constructor specifying bin interval, delta.
 bsta_histogram (const T min, const T max, vcl_vector< T > const &data, const T min_prob=0.0)
 construct from other histogram data.
 ~bsta_histogram ()
unsigned int nbins () const
T min () const
 min,max of total range.
T max () const
T delta () const
 bin interval.
T min_prob () const
 minimum probability.
void value_range (const unsigned int bin, T &vmin, T &vmax) const
 The value range for a bin.
T avg_bin_value (const unsigned int bin) const
 The average value for a bin.
T counts (const unsigned int bin) const
 The counts in a given bin.
T p (const unsigned int bin) const
 probability of a given bin.
T p (const T value) const
 probability of a value in the range.
T area () const
 Total area under the histogram.
T cumulative_area (unsigned bin) const
 The area under the histogram up to (excluding) the given bin.
T mean () const
 Mean of distribution.
T mean (const unsigned int lowbin, const unsigned int highbin) const
 Mean of distribution between bin indices.
T mean_vals (const T low, const T high) const
 Mean of distribution between values.
T variance () const
 Variance of distribution.
T variance (const unsigned int lowbin, const unsigned int highbin) const
 Variance of distribution between bin indices.
T variance_vals (const T low, const T high) const
 Variance of distribution between values.
unsigned low_bin ()
 First non-zero bin from below.
unsigned high_bin ()
 First non-zero bin from above.
T fraction_below (const T value) const
 Fraction of area less than val.
T fraction_above (const T value) const
 Fraction of area greater than val.
T value_with_area_below (const T area_fraction) const
 Value for area fraction below value.
T value_with_area_above (const T area_fraction) const
 Value for area fraction below value.
T entropy () const
 Entropy of p(x).
T renyi_entropy () const
 Renyi alpha = 2 entropy of p(x).
void upcount (T val, T mag)
 Increase the count of the bin corresponding to val by mag.
int bin_at_val (T val)
 Return the bin this element would fall on - it doesn't modify the current count.
void set_count (const unsigned bin, const T count)
 set the count for a given bin.
vcl_vector< T > value_array () const
 array of bin values.
vcl_vector< T > count_array () const
 array of bin counts.
void parzen (const T sigma)
 Smooth the histogram with a Parzen window of sigma.
vcl_ostream & write (vcl_ostream &) const
 Write to stream.
vcl_istream & read (vcl_istream &)
 Read from stream.
void pretty_print (vcl_ostream &os=vcl_cout) const
void print (vcl_ostream &os=vcl_cout) const
void print_to_m (vcl_ostream &os=vcl_cout) const
 print as a matlab plot command.
void print_to_arrays (vcl_ostream &os=vcl_cout) const
 print x and y arrays.
void print_vals_prob (vcl_ostream &os=vcl_cout) const
 print values and bin probability in full (even if counts ==0).
void clear ()
 restore default constructor state.
template<>
void pretty_print (vcl_ostream &os) const
template<>
void pretty_print (vcl_ostream &os) const
void ref ()
void unref ()
int get_references () const
bool is_referenced () const

Public Attributes

bsta_hist_type type_

Private Member Functions

void compute_area () const

Private Attributes

bool area_valid_
T area_
unsigned int nbins_
T range_
T delta_
T min_prob_
T min_
T max_
vcl_vector< T > counts_

Related Functions

(Note that these are not member functions.)

template<class T >
vcl_ostream & operator<< (vcl_ostream &s, bsta_histogram< T > const &h)
 Write histogram to stream.
template<class T >
vcl_istream & operator>> (vcl_istream &is, bsta_histogram< T > &h)
 Read histogram from stream.
template<class T >
void write_svg (const bsta_histogram< T > &h, const vcl_string &outfile, float width=600.0f, float height=600.0f, float margin=40.0f, int font_size=30)
 Create SVG document from histogram.

Detailed Description

template<class T>
class bsta_histogram< T >

Definition at line 22 of file bsta_histogram.h.


Member Enumeration Documentation

Enumerator:
HIST_TYPE_UNKNOWN 
HIST_TYPE_FLOAT 
HIST_TYPE_DOUBLE 
HIST_TYPE_END 

Definition at line 18 of file bsta_histogram_base.h.


Constructor & Destructor Documentation

template<class T >
bsta_histogram< T >::bsta_histogram ( )

Default constructor.

Definition at line 14 of file bsta_histogram.txx.

template<class T >
bsta_histogram< T >::bsta_histogram ( const T  range,
const unsigned int  nbins,
const T  min_prob = 0.0 
)

Simple constructor that assumes all data values are positive.

Definition at line 22 of file bsta_histogram.txx.

template<class T >
bsta_histogram< T >::bsta_histogram ( const T  min,
const T  max,
const unsigned int  nbins,
const T  min_prob = 0.0 
)

More general constructor defining a signed value range.

Definition at line 36 of file bsta_histogram.txx.

template<class T >
bsta_histogram< T >::bsta_histogram ( const unsigned int  nbins,
const T  min,
const T  delta,
const T  min_prob = 0.0 
)

More general constructor specifying bin interval, delta.

Definition at line 57 of file bsta_histogram.txx.

template<class T >
bsta_histogram< T >::bsta_histogram ( const T  min,
const T  max,
vcl_vector< T > const &  data,
const T  min_prob = 0.0 
)

construct from other histogram data.

Definition at line 73 of file bsta_histogram.txx.

template<class T>
bsta_histogram< T >::~bsta_histogram ( ) [inline]

Definition at line 44 of file bsta_histogram.h.


Member Function Documentation

template<class T >
T bsta_histogram< T >::area ( ) const

Total area under the histogram.

Definition at line 163 of file bsta_histogram.txx.

template<class T>
T bsta_histogram< T >::avg_bin_value ( const unsigned int  bin) const [inline]

The average value for a bin.

Definition at line 64 of file bsta_histogram.h.

template<class T >
int bsta_histogram< T >::bin_at_val ( T  val)

Return the bin this element would fall on - it doesn't modify the current count.

Definition at line 103 of file bsta_histogram.txx.

template<class T >
void bsta_histogram< T >::clear ( )

restore default constructor state.

Definition at line 406 of file bsta_histogram.txx.

template<class T >
void bsta_histogram< T >::compute_area ( ) const [private]

Definition at line 116 of file bsta_histogram.txx.

template<class T>
vcl_vector<T> bsta_histogram< T >::count_array ( ) const [inline]

array of bin counts.

Definition at line 141 of file bsta_histogram.h.

template<class T>
T bsta_histogram< T >::counts ( const unsigned int  bin) const [inline]

The counts in a given bin.

Definition at line 68 of file bsta_histogram.h.

template<class T >
T bsta_histogram< T >::cumulative_area ( unsigned  bin) const

The area under the histogram up to (excluding) the given bin.

Definition at line 125 of file bsta_histogram.txx.

template<class T>
T bsta_histogram< T >::delta ( ) const [inline]

bin interval.

Definition at line 54 of file bsta_histogram.h.

template<class T >
T bsta_histogram< T >::entropy ( ) const

Entropy of p(x).

Definition at line 269 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::fraction_above ( const T  value) const

Fraction of area greater than val.

Definition at line 349 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::fraction_below ( const T  value) const

Fraction of area less than val.

Definition at line 330 of file bsta_histogram.txx.

template<class T >
unsigned bsta_histogram< T >::high_bin ( )

First non-zero bin from above.

Definition at line 321 of file bsta_histogram.txx.

template<class T >
unsigned bsta_histogram< T >::low_bin ( )

First non-zero bin from below.

Definition at line 312 of file bsta_histogram.txx.

template<class T>
T bsta_histogram< T >::max ( ) const [inline]

Definition at line 51 of file bsta_histogram.h.

template<class T >
T bsta_histogram< T >::mean ( ) const

Mean of distribution.

Definition at line 172 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::mean ( const unsigned int  lowbin,
const unsigned int  highbin 
) const

Mean of distribution between bin indices.

Definition at line 179 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::mean_vals ( const T  low,
const T  high 
) const

Mean of distribution between values.

Definition at line 197 of file bsta_histogram.txx.

template<class T>
T bsta_histogram< T >::min ( ) const [inline]

min,max of total range.

Definition at line 50 of file bsta_histogram.h.

template<class T>
T bsta_histogram< T >::min_prob ( ) const [inline]

minimum probability.

Definition at line 57 of file bsta_histogram.h.

template<class T>
unsigned int bsta_histogram< T >::nbins ( ) const [inline]

Definition at line 47 of file bsta_histogram.h.

template<class T >
T bsta_histogram< T >::p ( const unsigned int  bin) const

probability of a given bin.

Definition at line 134 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::p ( const T  value) const

probability of a value in the range.

Definition at line 147 of file bsta_histogram.txx.

template<class T >
void bsta_histogram< T >::parzen ( const T  sigma)

Smooth the histogram with a Parzen window of sigma.

Definition at line 297 of file bsta_histogram.txx.

template<>
void bsta_histogram< char >::pretty_print ( vcl_ostream &  os) const

Definition at line 5 of file bsta_histogram.cxx.

template<class T >
void bsta_histogram< T >::pretty_print ( vcl_ostream &  os = vcl_cout) const

Definition at line 422 of file bsta_histogram.txx.

template<>
void bsta_histogram< char >::pretty_print ( vcl_ostream &  os) const
template<class T >
void bsta_histogram< T >::print ( vcl_ostream &  os = vcl_cout) const

Definition at line 414 of file bsta_histogram.txx.

template<class T >
void bsta_histogram< T >::print_to_arrays ( vcl_ostream &  os = vcl_cout) const

print x and y arrays.

Definition at line 455 of file bsta_histogram.txx.

template<class T >
void bsta_histogram< T >::print_to_m ( vcl_ostream &  os = vcl_cout) const

print as a matlab plot command.

Definition at line 440 of file bsta_histogram.txx.

template<class T >
void bsta_histogram< T >::print_vals_prob ( vcl_ostream &  os = vcl_cout) const

print values and bin probability in full (even if counts ==0).

Definition at line 468 of file bsta_histogram.txx.

template<class T >
vcl_istream & bsta_histogram< T >::read ( vcl_istream &  s)

Read from stream.

Definition at line 492 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::renyi_entropy ( ) const

Renyi alpha = 2 entropy of p(x).

Definition at line 283 of file bsta_histogram.txx.

template<class T>
void bsta_histogram< T >::set_count ( const unsigned  bin,
const T  count 
) [inline]

set the count for a given bin.

Definition at line 132 of file bsta_histogram.h.

template<class T >
void bsta_histogram< T >::upcount ( T  val,
T  mag 
)

Increase the count of the bin corresponding to val by mag.

Definition at line 88 of file bsta_histogram.txx.

template<class T>
vcl_vector<T> bsta_histogram< T >::value_array ( ) const [inline]

array of bin values.

Definition at line 136 of file bsta_histogram.h.

template<class T>
void bsta_histogram< T >::value_range ( const unsigned int  bin,
T &  vmin,
T &  vmax 
) const [inline]

The value range for a bin.

Definition at line 60 of file bsta_histogram.h.

template<class T >
T bsta_histogram< T >::value_with_area_above ( const T  area_fraction) const

Value for area fraction below value.

Definition at line 386 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::value_with_area_below ( const T  area_fraction) const

Value for area fraction below value.

Definition at line 366 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::variance ( ) const

Variance of distribution.

Definition at line 219 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::variance ( const unsigned int  lowbin,
const unsigned int  highbin 
) const

Variance of distribution between bin indices.

Definition at line 227 of file bsta_histogram.txx.

template<class T >
T bsta_histogram< T >::variance_vals ( const T  low,
const T  high 
) const

Variance of distribution between values.

Definition at line 248 of file bsta_histogram.txx.

template<class T >
vcl_ostream & bsta_histogram< T >::write ( vcl_ostream &  s) const

Write to stream.

Definition at line 475 of file bsta_histogram.txx.


Friends And Related Function Documentation

template<class T >
vcl_ostream & operator<< ( vcl_ostream &  s,
bsta_histogram< T > const &  h 
) [related]

Write histogram to stream.

template<class T >
vcl_istream & operator>> ( vcl_istream &  is,
bsta_histogram< T > &  h 
) [related]

Read histogram from stream.

template<class T >
void write_svg ( const bsta_histogram< T > &  h,
const vcl_string &  outfile,
float  width = 600.0f,
float  height = 600.0f,
float  margin = 40.0f,
int  font_size = 30 
) [related]

Create SVG document from histogram.

Definition at line 21 of file bsta_svg_tools.h.


Member Data Documentation

template<class T>
T bsta_histogram< T >::area_ [mutable, private]

Definition at line 173 of file bsta_histogram.h.

template<class T>
bool bsta_histogram< T >::area_valid_ [mutable, private]

Definition at line 172 of file bsta_histogram.h.

template<class T>
vcl_vector<T> bsta_histogram< T >::counts_ [private]

Definition at line 180 of file bsta_histogram.h.

template<class T>
T bsta_histogram< T >::delta_ [private]

Definition at line 176 of file bsta_histogram.h.

template<class T>
T bsta_histogram< T >::max_ [private]

Definition at line 179 of file bsta_histogram.h.

template<class T>
T bsta_histogram< T >::min_ [private]

Definition at line 178 of file bsta_histogram.h.

template<class T>
T bsta_histogram< T >::min_prob_ [private]

Definition at line 177 of file bsta_histogram.h.

template<class T>
unsigned int bsta_histogram< T >::nbins_ [private]

Definition at line 174 of file bsta_histogram.h.

template<class T>
T bsta_histogram< T >::range_ [private]

Definition at line 175 of file bsta_histogram.h.

Definition at line 30 of file bsta_histogram_base.h.


The documentation for this class was generated from the following files: