# cPSquare Class Reference
[Statistical data collection]

`#include <cpsquare.h>`

Inheritance diagram for cPSquare:

List of all members.

## Detailed Description

Implements the P2 algorithm, which calculates quantile values without storing the observations.

## Public Member Functions

Constructors, destructor, assignment.
| cPSquare (const cPSquare &r)
| cPSquare (const char *name=NULL, int cells=10)
virtual | ~cPSquare ()
cPSquare & | operator= (const cPSquare &res)
Redefined cObject member functions.
virtual cPolymorphic * | dup () const
virtual void | netPack (cCommBuffer *buffer)
virtual void | netUnpack (cCommBuffer *buffer)
virtual void | writeContents (std::ostream &os)
Redefined member functions from cStatistic and its subclasses.
virtual void | transform ()
virtual void | setRange (double, double)
virtual void | setRangeAuto (int, double)
virtual void | setRangeAutoLower (double, int, double)
virtual void | setRangeAutoUpper (double, int, double)
virtual void | setNumFirstVals (int)
virtual int | cells () const
virtual double | basepoint (int k) const
virtual double | cell (int k) const
virtual double | cdf (double x) const
virtual double | pdf (double x) const
virtual double | random () const
virtual void | saveToFile (FILE *) const
virtual void | loadFromFile (FILE *)

## Protected Member Functions

virtual void | collectTransformed (double val)

## Constructor & Destructor Documentation

cPSquare::cPSquare | ( | const cPSquare & | r | ) |

| Copy constructor.

cPSquare::cPSquare | ( | const char * | name = `NULL`,
|  | int | cells = `10`
| ) | `[explicit]`

| Constructor.

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

| Destructor.

## Member Function Documentation

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

| Returns the kth cell boundary. Note that because of the P2 algorithm, cell boundaries are shifting during data collection, thus cell() and other methods based on cell() and basepoint() return approximate values. Implements cDensityEstBase.

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

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

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

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

virtual int cPSquare::cells | ( |  | ) | const`[virtual]`

| Returns the number of cells used. Implements cDensityEstBase.

virtual void cPSquare::collectTransformed | ( | double | val | ) | `[protected, virtual]`

| Called internally by collect(), this method updates the P2 data structure with the new value. Implements cDensityEstBase.

virtual cPolymorphic* cPSquare::dup | ( |  | ) | const`[inline, virtual]`

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

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

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

virtual void cPSquare::netPack | ( | cCommBuffer * | buffer | ) | `[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 cDensityEstBase.

virtual void cPSquare::netUnpack | ( | cCommBuffer * | buffer | ) | `[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 cDensityEstBase.

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

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

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

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

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

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

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

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

virtual void cPSquare::setNumFirstVals | ( | int |  | ) | `[inline, virtual]`

| setRange() and setNumFirstVals() methods are not used with cPSquare (the algorithm doesn't require them), but they could not remain pure virtual. Reimplemented from cDensityEstBase.

virtual void cPSquare::setRange | ( | double | ,
|  | double |
| ) | `[inline, virtual]`

| setRange() and setNumFirstVals() methods are not used with cPSquare (the algorithm doesn't require them), but they could not remain pure virtual. Reimplemented from cDensityEstBase.

virtual void cPSquare::setRangeAuto | ( | int | ,
|  | double |
| ) | `[inline, virtual]`

| setRange() and setNumFirstVals() methods are not used with cPSquare (the algorithm doesn't require them), but they could not remain pure virtual. Reimplemented from cDensityEstBase.

virtual void cPSquare::setRangeAutoLower | ( | double | ,
|  | int | ,
|  | double |
| ) | `[inline, virtual]`

| setRange() and setNumFirstVals() methods are not used with cPSquare (the algorithm doesn't require them), but they could not remain pure virtual. Reimplemented from cDensityEstBase.

virtual void cPSquare::setRangeAutoUpper | ( | double | ,
|  | int | ,
|  | double |
| ) | `[inline, virtual]`

| setRange() and setNumFirstVals() methods are not used with cPSquare (the algorithm doesn't require them), but they could not remain pure virtual. Reimplemented from cDensityEstBase.

virtual void cPSquare::transform | ( |  | ) | `[inline, virtual]`

| This method is not used with cPSquare, but it could not remain pure virtual. Implements cDensityEstBase.

virtual void cPSquare::writeContents | ( | std::ostream & | os | ) | `[virtual]`

| Writes textual information about this object to the stream. See cObject for more details. Reimplemented from cDensityEstBase.

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

- cpsquare.h