RandomNumber Class Reference

Parallel data structure for manipulating random numbers. More...

#include <random_number.h>

List of all members.

Public Member Functions

 RandomNumber ()
 RandomNumber (int num_samples)
 RandomNumber (int num_samples, int num_ghosts)
 ~RandomNumber ()
void set_size (int num_samples)
 Allocates space for a random number even distributed across the cores.
void set_ghost_size (int num_samples, int num_ghosts)
 Allocates space for a ghost padded random number even distributed across the cores.
void make_uniform (int seed) const
 Gives the random number a uniform distribution.
void make_normal (double mu, double sigma, int seed) const
 Gives the random number a normal distribution.
double mean ()
 Returns the sample mean and stores it for future use.
double variance ()
 Returns the unbiased sample variance and stores it for future use.
double min ()
 Returns the sample minimum and stores it for future use.
double max ()
 Returns the sample maximum and stores it for future use.
void create_frequency_table (int num_bins, bool normalized)
 Uses an STL vector array to store the frequency table.
void print_frequency_table (std::string file_name, int num_bins, Distribution &dist) const
double get_quantile (int alpha)
void view (void) const
 Write the random number to the screen.
void print (std::string file_name) const

Public Attributes

std::vector< double > * frequency_table
ddata::Vector samples

Private Attributes

int num_samples
double * sample_min
double * sample_max
double * sample_mean
double * sample_variance


Detailed Description

Parallel data structure for manipulating random numbers.

Constructor & Destructor Documentation

RandomNumber::RandomNumber (  ) 

RandomNumber::RandomNumber ( int  num_samples  ) 

RandomNumber::RandomNumber ( int  num_samples,
int  num_ghosts 
)

RandomNumber::~RandomNumber (  ) 


Member Function Documentation

void RandomNumber::set_size ( int  num_samples_  ) 

Allocates space for a random number even distributed across the cores.

Parameters:
num_samples : The number of samples.

void RandomNumber::set_ghost_size ( int  num_samples_,
int  num_ghosts 
)

Allocates space for a ghost padded random number even distributed across the cores.

Parameters:
num_samples : The number of samples.
num_ghosts : The number of ghost points.

void RandomNumber::make_uniform ( int  seed  )  const

Gives the random number a uniform distribution.

Parameters:
seed : True seeds the generator, false does not.

void RandomNumber::make_normal ( double  mu,
double  sigma,
int  seed 
) const

Gives the random number a normal distribution.

Parameters:
mu : The mean.
sigma : The square root of the variance.
seed : True seeds the generator, false does not.
This implementation uses the Box-Muller method. Given two independent random numbers $U_1~U(0,1)$ and $U_2~U(0,1)$, the transformed variables $N_1=\sqrt{R}\sin{V}$ and $N_2=\sqrt{R}\cos{V}$ are independent with a distribution of $N(0,1)$. Where
$ R = -2\log{U_1}$
$ V = 2 \pi U_2 $

double RandomNumber::mean (  ) 

Returns the sample mean and stores it for future use.

double RandomNumber::variance (  ) 

Returns the unbiased sample variance and stores it for future use.

double RandomNumber::min (  ) 

Returns the sample minimum and stores it for future use.

double RandomNumber::max (  ) 

Returns the sample maximum and stores it for future use.

void RandomNumber::create_frequency_table ( int  num_bins,
bool  normalized 
)

Uses an STL vector array to store the frequency table.

Parameters:
num_bins : The number of bins.
normalized : If true the area under the frequency curve is 1.0. If false then the actual frequencies are computed.
The observed frequencies are stored in frequency_table[1] while the ranges are stored in frequency_table[0]. The frequency table only covers the sample min and sample max.
frequency_table[0][i]=$X_i$
frequency_table[1][i]=$F_i=\sum_j^n I(X_i \le x_j < X_{i+1})$

void RandomNumber::print_frequency_table ( std::string  file_name,
int  num_bins,
Distribution dist 
) const

double RandomNumber::get_quantile ( int  alpha  ) 

void RandomNumber::view ( void   )  const

Write the random number to the screen.

void RandomNumber::print ( std::string  file_name  )  const


Member Data Documentation

double* RandomNumber::sample_min [private]

double* RandomNumber::sample_max [private]

double* RandomNumber::sample_mean [private]

double* RandomNumber::sample_variance [private]

std::vector<double>* RandomNumber::frequency_table


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

Documentation generated by  doxygen
Source code hosted by