PROFASI  Version 1.5
Public Member Functions | List of all members
prf_utils::His2D Class Reference

A histogram with 2 independent variables. More...

#include <His2D.hh>

Public Member Functions

His2Doperator= (const His2D &)
 One can assign a histogram to another.
void init ()
 Necessary to call this after specifying number of bins etc.
void reset ()
 Does not deallocate memory, but clears the collected statistics.
void Range (double x0, double x1, double x2, double x3)
 Set range in x and y directions.
void XRange (double x0, double x1)
 Set only the x range.
void YRange (double x0, double x1)
 Set only the y range.
void NXbins (int v)
 Set the number of bins in the X-axis.
void NYbins (int v)
 Set the number of bins in the Y-axis.
int NXbins () const
 Return the current number of bins in the X-axis.
int NYbins () const
 Return the current number of bins in the Y-axis.
double Xmin () const
 Return the lower limit of the current X-range.
double Xmax () const
 Return the upper limit of the current X-range.
double Ymin () const
 Return the lower limit of the current Y-range.
double Ymax () const
 Return the upper limit of the current Y-range.
double xval (int i)
 X value for the i'th bin on the X-axis.
double yval (int i)
 Y value for the i'th bin on the Y-axis.
double val (int i, int j)
 Z value for the i'th bin along X and j'th bin along Y-axis.
int put (double x, double y)
 Put a new datapoint (x,y) into the histogram.
double normalize ()
 Convert the collected frequency data to probabilities.
void Export (const char *filename, int fmt=3)
 Save histogram information in a file for plotting.
int Import (const char *filename)
 Read back histogram information from exported text files.
void save_state (const char *filename)
 Save current state of sampling in a binary file to resume counting later.
void read_state (const char *filename)
 Retrieve stored sampling state to resume counting.
His2Doperator+= (const His2D &)
 Add the contents of another histogram.
void Projection_X (std::vector< double > &hsx)
 For each x, return Sum z(x,y) | y=0..ymax.
void Projection_Y (std::vector< double > &hsy)
 For each y, return Sum z(x,y) | x=0..xmax.

Detailed Description

His2D represents histograms of the type dP/dxdy to chart out the probability distribution of a variable z as a function of two variables x and y.

Data can be stored in two supported layouts in text files. To describe we use the notation zij=P(xi,yj).

The layout means, when the histogram data is written to a file, it is formatted like this:

x0 y0 z00
x0 y1 z01
x0 y2 z02
x0 yn z0n

x1 y0 z10
x1 y1 z11

In the second supported data layout, the data is saved in 3 files. One representing just the x values, { x0, x1,... }, one with only the y values {y1,y2 ...}, and one with the z values :

z00 z01 z02 ... z0n
z10 z11 z12 ... z1n
z20 ...
where n is (n_ybins -1) This format takes less space on disk. It became the default layout in PROFASI v 1.4.

Member Function Documentation

int His2D::Import ( const char *  filename)

Import is only implemented for files exported with the default format, fmt=3. In this format, there are a few comment lines beginning with "#" giving ranges and number of bins. Then there is a matrix M of data of (nxbins+1) rows and (nybins+1) columns. The top-left element, with index (0,0) is always 0. The elements M[0,1+j], for j in the range (0,nybins) are the centres of the ybins for the data. Similarly, M[1+i,0] for i in range (0,nxbins) are the centres of xbins. The elements M[1+i,1+j] with i in range (0,nxbins) and j in range (0,nybins) then represent the probabilities P(X[i],Y[j]).

double His2D::normalize ( )

After a call to normalize, the sum of all elements in the histogram is 1, provided all attempted put(x,y) operations succeeded, i.e., there were no out of range values.

int His2D::put ( double  x,
double  y 

We are concerned with keeping track of how often an certain combination (x,y) occurs. This function should be called for every sampling event. Then after a large number of sampling events, the histogram will contain the probabilities (frequencies, if not normalized) for the different (x,y) pairs.

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

PROFASI: Protein Folding and Aggregation Simulator, Version 1.5
© (2005-2016) Anders Irbäck and Sandipan Mohanty
Documentation generated on Mon Jul 18 2016 using Doxygen version 1.8.2