proc.h provides classes and functions for generating pseudo random numbers for all of the distributions in dist.h. This functionality is provided in two forms:
The functions take one or more uniformly distributed random numbers as input and so can be used with any random number generator. They are intended to be fast for distributions which model actual statistical distributions such as normal or Weibull. For distributions which are used to model sample statistics such as Student's t or chi square the generators are intended to facilitate understanding the statistic and can actually be very slow in some cases.
The polymorphic data types are template classes where the random number generator is the template type. Thus the type
WeibullPG<Good1>
is a Weibull process generator using Good1 as its random number generator. Any object which uses operator()() to create a random number in [0..1] can be used as the template type. A pointer to an actual instance of the random number is required in the constructor. This reflects the fact that you want all your process generators to share a common stream of random numbers so they are not correlated to each other.
The polymorphic types are derived from IDiProc for discrete random variables and ICoDist for continuous random variables. They are also derived from IDiDist and ICoDist respectively. These are called "smart process generators" because they know many details about the statistics of the numbers they generate.
The discrete process generators supported in the current release are:
| Common Name | Fast Generator | Smart Generator |
|---|---|---|
| constant | (none) | DiConstPG |
| uniform | genDiUnif | DiUnifPG |
| Bernoulli | genBernoulli | BernoulliPG |
| binomial | genBinomial | BinomialPG |
| hypergeometric | genHyperg | HypergPG |
| Poisson | genPoisson | PoissonPG |
The continuous process generators supported in the current release are:
| Common Name | Fast Generator | Smart Generator |
|---|---|---|
| constant | (none) | CoConstPG |
| uniform | genCoUnif | CoUnifPG |
| exponential | genExpon | ExponPG |
| Weibull | genWeibull | WeibullPG |
| Rayleigh | genRayleigh | RayleighPG |
| normal | genNormal | NormalPG |
| log normal | genLognor | LognorPG |
| chi-squared | genChisq | ChisqPG |
| F | genSnedecor_F | Snedecor_FPG |
| Student's t | genStudent_t | Student_tPG |
In C++ standard library terms a process generator could be thought of as an input iterator. In support of this idea UVS provides an input iterator named proc_input_iterator<PROC> where "PROC" is one of the process generators listed above. There are two convenience functions for creating the iterator class which could be used as follows:
#include <vector> // for std::vector #include <algorithm> // for std::copy #include "uvs/rng.h" // for uvs::Good1 #include "uvs/proc.h" // for uvs::WeibullPG, uvs::proc_begin, and uvs::proc_end typedef uvs::Good1 RNG; RNG rng; uvs::WeibullPG my_proc(&rng, 1.2, 0.9); std::vector<double> my_vec; std::copy(uvs::proc_begin(my_proc, 100), uvs::proc_end(my_proc), std::back_inserter(my_vec));This will store 100 variates in my_vec. See the header file for details.