#include <His1D.hh>
Inherited by prf_utils::AdaptiveHis.
Inheritance diagram for prf_utils::His1D:

Public Member Functions | |
| His1D () | |
| Default constructor. | |
| His1D (int nbl) | |
| Create His1D with nbl blocks (create nbl histograms). | |
| His1D (double xmn, double xmx, int npnts, int numblocks=1) | |
| Construct with xmin, xmax, number of bins and number of blocks. | |
| His1D (const His1D &) | |
| Copy constructor (copies data, so do not initialize after this!). | |
| His1D & | operator= (const His1D &) |
| Assignment operator (copies data, do not initialize after this!). | |
| void | init () |
| Initializes using info about range etc. | |
| void | reset () |
| Reset all data (init calls this). | |
| void | NBlocks (int n) |
| Make it a histogram of n blocks. | |
| int | NBlocks () const |
| Return the number of blocks. | |
| long | n_entries (int i) const |
| number of entries in block i | |
| long | n_entries_in_range (int i) const |
| number of entries in block i in range | |
| void | Range (double x0, double x1) |
| Set range. | |
| void | Nbins (int v) |
| Set number of bins. | |
| int | Nbins () const |
| Get number of bins. | |
| double | Xmin () const |
| Get xmin. | |
| double | Xmax () const |
| Get xmax. | |
| double | Xbin () const |
| Get bin size. | |
| double | xval (int i) |
| x value for the middle of i'th bin | |
| double | yval (int iblk, int i) |
| y value for the middle of i'th bin | |
| int | put (double x, int iblk=0) |
| put value x into the iblk block | |
| int | nput (int howmanytimes, double x, int iblk) |
| put n indentical values at once | |
| double | normalize () |
| normalize histogram so that each block sums to 1 | |
| double | unnormalize () |
| unnormalize histogram so that each block sums to its occupancy | |
| virtual void | Export (const char *filename, int normmode=2) |
| Export data in text format to a given file. | |
| int | Import (const char *filename) |
| Import histogram data written in the format of Export function. | |
| His1D & | operator+= (const His1D &) |
| Add information from another given histogram. | |
Besides, His1D will have one significant aspect built in which was absent in the Histogram. It is the ability to read in the state of a histogram from a file, and hence to restore histograms to given states and to combine histogram data from different files into one properly normalized histogram. This is useful, for instance, when one has 100 simulated tempering runs with 8 temperatures for the same system, and it is of interest to combine the information from all runs to generate one set of grand histograms, as if it were obtained from a single run 100 times as long.
Another important change is that this histogram class is intrinsically indexed. Meaning, if you need 8 histograms for the same quantity corresponding to 8 values of some state designator, you only need one His1D. But you give it 8 blocks with the NBlocks(int) function. If you do not create it with multiple blocks or assign blocks with the NBlocks function it will remain a single histogram. Data for different blocks are written into the same output file, and ofcourse, each block is separately normalized. Data is written into the output file as
x dP/dx
In case there are many blocks of data, an additional column is added to the LEFT. The first column then means the block id, while the other columns are moved.
| void His1D::Export | ( | const char * | filename, | |
| int | normmode = 2 | |||
| ) | [virtual] |
There are 3 ways this class can save data to a file. If normmode is set to 0, it saves data as it is. This means that the data will be raw frequencies if the histogram is unnormalized, and the fraction (bin occupancy/number of data points) if it is normalized. For mode 1, the data is saved in the normalized version, while the histogram remains unchanged. For mode 2, the data is saved with a further division by the binsize. So, in mode 2, the data can be interpreted as dP/dx, and will get similar values for the same system even if you change the bin size. The values in mode 1 are dP/dx * dx, the probability of the data to be in that bin. This of course, should change with bin size. Mode 2 is default.
Reimplemented in prf_utils::AdaptiveHis.