1#ifndef UTIL_INT_DISTRIBUTION_H
2#define UTIL_INT_DISTRIBUTION_H
11#include <util/param/ParamComposite.h>
12#include <util/containers/DArray.h>
89 template <
class Archive>
90 void serialize(Archive& ar,
const unsigned int version);
109 void output(std::ostream& out);
160 {
return (value -
min_); }
183 template <
class Archive>
Saving archive for binary istream.
Saving / output archive for binary ostream.
Dynamically allocatable contiguous array template.
A distribution (or histogram) of values for an int variable.
IntDistribution()
Default constructor.
virtual ~IntDistribution()
Destructor.
void setParam(int min, int max)
Set parameters and initialize.
int nSample_
Number of sampled values in Histogram.
const DArray< long > & data() const
Get histogram array.
int max() const
Get maximum value in range of histogram.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
int binIndex(int value)
Return the index of the bin for a value.
virtual void save(Serializable::OArchive &ar)
Save state to an archive.
void sample(int value)
Sample a value.
int nBin() const
Get the number of bins.
DArray< long > histogram_
Histogram array.
IntDistribution & operator=(const IntDistribution &other)
Assignment operator.
void readParameters(std::istream &in)
Read parameters from file and initialize.
int min() const
Get minimum value in range of histogram.
void output(std::ostream &out)
Output the distribution to file.
void serialize(Archive &ar, const unsigned int version)
Serialize to/from an archive.
int nReject_
Number of sampled values that were out of range.
void clear()
Clear (i.e., zero) previously allocated histogram.
An object that can read multiple parameters from file.
Utility classes for scientific computation.