Main Page Modules Class Hierarchy Compound List File List Compound Members

# cVarHistogram Class Reference

`#include <cvarhist.h>`

Inheritance diagram for cVarHistogram::

List of all members.

## Public Methods
Constructors, destructor, assignment.
| cVarHistogram (const cVarHistogram &r)
| cVarHistogram (const char *name=NULL, int numcells=11, int transformtype=HIST_TR_AUTO_EPC_DBL)
virtual | ~cVarHistogram ()
cVarHistogram& | operator= (const cVarHistogram &res)
Redefined cObject member functions.
virtual cObject* | dup () const
virtual int | netPack ()
virtual int | netUnpack ()
Redefined member functions from cStatistic and its subclasses.
virtual void | clearResult ()
virtual void | transform ()
virtual void | collectTransformed (double val)
virtual double | random () const
virtual double | pdf (double x) const
virtual double | cdf (double x) const
virtual double | basepoint (int k) const
virtual double | cell (int k) const
virtual void | saveToFile (FILE *) const
virtual void | loadFromFile (FILE *)
Setting up the histogram.
virtual void | addBinBound (double x)
## Protected Methods
void | createEquiProbableCells ()

## Detailed Description

Variable bin size histogram. You may add cell (bin) boundaries manually, or .let the object create cells with equal number of observations in them (or as close to that as possible).

Transform types for cVarHistogram:

- HIST_TR_NO_TRANSFORM: no transformation; uses bin boundaries previously defined by addBinBound()/appendBinBound()
- HIST_TR_AUTO_EPC_DBL: automatically creates equiprobable cells
- HIST_TR_AUTO_EPC_INT: like the above, but uses a different hack :-)

Layout of the variable bin width histogram:

            underflow-cell   ordinary cells . . .             overflow-cell
            ...---------|-----------|- ... -|-----------------|---------...
                        | ^cellv[0] |      cellv[num_cells-1]^|
                      n |           |                         |
                    rangemin        |                      rangemax
                        |    bin_bounds[1]                    |
                  bin_bounds[0]                       bin_bounds[numcells]

Rangemin and rangemax is chosen after collecting the num_firstvals initial observations. It is not possible to add cell boundaries when histogram is already transformed.

Now we do support the following 2 uses of cVarHistogram:

1. add all the boundaries (manually) before collecting samples
2. collect samples and transform() makes the boundaries

## Constructor & Destructor Documentation

cVarHistogram::cVarHistogram ( | const cVarHistogram & r )`[inline]`

| Copy constructor.

cVarHistogram::cVarHistogram ( | const char * name = NULL,
| int numcells = 11,
| int transformtype = HIST_TR_AUTO_EPC_DBL )`[explicit]`

| Constructor. The third argument can be one of HIST_TR_NO_TRANSFORM, HIST_TR_AUTO_EPC_DBL, HIST_TR_AUTO_EPC_INT.

cVarHistogram::~cVarHistogram ( | )`[virtual]`

| Destructor.

## Member Function Documentation

void cVarHistogram::addBinBound ( | double x )`[virtual]`

| FIXME: Adds a new bin boundary (keeping the right order). If HIST_TR_NO_TRANSFORM was passed in the constructor call, you may specify cell (bin) bounds manually before collection starts.

double cVarHistogram::basepoint ( | int k ) const`[virtual]`

| Returns the kth cell boundary. Reimplemented from cDensityEstBase.

double cVarHistogram::cdf ( | double x ) const`[virtual]`

| Returns the value of the Cumulated Density Function at a given x. Reimplemented from cDensityEstBase.

double cVarHistogram::cell ( | int k ) const`[virtual]`

| Returns the number of observations that fell into the kth histogram cell. Reimplemented from cDensityEstBase.

void cVarHistogram::clearResult ( | )`[virtual]`

| Clears the results collected so far. Reimplemented from cHistogramBase.

void cVarHistogram::collectTransformed ( | double val )`[virtual]`

| Called internally by collect(), this method collects a value after the histogram has been transformed. Reimplemented from cDensityEstBase.

void cVarHistogram::createEquiProbableCells ( | )`[protected]`

| FIXME:

cObject * cVarHistogram::dup ( | ) const`[inline, virtual]`

| Creates and returns an exact copy of this object. See cObject for more details. Reimplemented from cStdDev.

void cVarHistogram::loadFromFile ( | FILE * )`[virtual]`

| Reads the object data from a file, in the format written out by saveToFile(). Reimplemented from cHistogramBase.

int cVarHistogram::netPack ( | )`[virtual]`

| Serializes the object into a PVM or MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cHistogramBase.

int cVarHistogram::netUnpack ( | )`[virtual]`

| Deserializes the object from a PVM or MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cHistogramBase.

cVarHistogram & cVarHistogram::operator= ( | const cVarHistogram & res )

| Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details.

double cVarHistogram::pdf ( | double x ) const`[virtual]`

| Returns the value of the Probability Density Function at a given x. Reimplemented from cDensityEstBase.

double cVarHistogram::random ( | ) const`[virtual]`

| Generates a random number based on the collected data. Uses the random number generator set by setGenK(). Reimplemented from cDensityEstBase.

void cVarHistogram::saveToFile ( | FILE * ) const`[virtual]`

| Writes the contents of the object into a text file. Reimplemented from cHistogramBase.

void cVarHistogram::transform ( | )`[virtual]`

| Transforms the table of precollected values into an internal histogram structure. Reimplemented from cHistogramBase.

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

- cvarhist.h