This is a work-in-progress repository which provides a module for randomly generated real numbers, complex numbers, matrices in iRRAM.
iRRAM is a open source C++ library for real number computation (Exact Real Arithmetic). It is developed in University of Trier. For more information, visit http://irram.uni-trier.de
For the sake of advertising, below is what iRRAM can do:
#include iRRAM.h
void compute()
{
REAL x = pi();
cout << setRwidth(100);
cout << x
}+.31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253E+0001
You first need to be comfortable working with iRRAM. For this, see iRRAM's documentation and example codes.
If you use irramsh, the package manager for iRRAM, you can install this random package simply by
$ irramsh install irram-random
then import irram-random to your project:
yourproject.cc
...
#include "irram-random.h"
...
REALMATRIX O = haar_orthogonal_matrix(100);Then compile it easily by
$ irramsh -o randommatrix.out yourjroject.ccRandom object generators in each header file is explained below. irram-random.h includes all these header file. Hence, if it is feasible, it is okay to include only the irram-random.h:
-
REAL uniform_real() returns uniformlly distributed real number in (0,1)
-
REAL uniform_real(REAL a, REAL b) returns a uniformly distributed real number in (a, b)
-
REAL gaussian_real() returns a normally distributed real number
-
REAL gaussian_real(REAL e, REAL std) returns a normally distributed real number with average e and standard deviation std.
-
REAL linear_real() returns a random real number follows distribution p(x) = 2*x in (0,1)
-
COMPLEX uniform_complex() returns a uniformly distributed complex number in a unit disc
-
COMPLEX uniform_complex(COMPLEX c, REAL r) returns a uniformly distributed complex number in a disc centered at c with radius r
-
COMPLEX gaussian_complex() returns a normally distributed complex number
-
REALMATRIX gaussian_symmetric_matrix(unsigned int n) returns a
$n \times n$ random symmetric matrix where each entry is normally distributed. -
REALMATRIX gaussian_asymmetric_matrix(unsigned int n) returns a
$n \times n$ random asymmetric matrix where each entry is normally distributed. -
REALMATRIX gaussian_matrix(unsigned int n) returns a
$n \times n$ random matrix where each entry is normally distributed. -
REALMATRIX haar_orthogonal_matrix(unsigned int n) returns a
$n \times n$ random orthogonal matrix which follows Haar distribution in$O(n)$ . See [Stewart, Gilbert W. "The efficient generation of random orthogonal matrices with an application to condition estimators." SIAM Journal on Numerical Analysis 17.3 (1980): 403-409.] for more detail.
The file plot.cc is a iRRAM source code which plots i.i.d random variables on a Terminal. The code is written intuitively. Try various distributions to plot! Have fun!
Source files in src_official is compatible with the iRRAM official release version of 201401.
Source files in src works with in-development version of iRRAM https://github.com/fbrausse/iRRAM.git commit# 3ea239a720d (Jan. 2017).
Try using irram.sh which is a version and package controller of iRRAM if you need to work with various versions at once.
The generator is based on C++ std library's random integer generator. Inductively thinking, at first we create a random integer. For some precision
iRRAM's reiteration cache is used to make the random number consistent; existing integer should not be re-generated. Hence, to follow iRRAM's spirit of hiding reiteration, the part is hidden in random-core.cc file.
After having the uniformly distributed random number generator, it is used to make normal distribution and other randomly distributed objects. (e.g., see https://en.wikipedia.org/wiki/Box–Muller_transform)
-
Datatypes for complex matrices
-
random hermitian and unitary matrices.
-
Add examples for random matrices
-
More useful random objects...