FUNCTIONS:

int irandom(int n):
random integer between 0 and n (inclusive)
float frandom(float n):
random number between 0 and n (inclusive)
void srandom(int seed):
init random generator.
float *rnd_vec(int dim,float limit1=0,float limit2=1)
generate dim dimensional random vector with elements uniformly distributed between limit1 and limit2.
float *rnd_vec(int dim, float *limit1,float *limit2=NULL)
dito, but now with elementwise limits. If limit2=NULL, all limit2's will be chosen as zero.
float *grnd_vec(int dim)
generate dim dimensional gaussian random vector whose elements are i.i.d. gaussian with variance of 1 and mean zero.
float *grnd_vec(float *stdev)
generate dimof(stdev) dimensional gaussian random vector with standard deviations given by stdev along each axis.
(for gaussian random vectors with distribution in general position, use class mog() below with 1 component)
int rnd_wta(float *value, float beta, int stride)
probabilistic winner-takes-all sampling: will return an integer in the range 0..d-1 where d=dimof(value)/stride. The probability of return value k will be N*exp(beta*value[k*stride]), where N is a normalization factor. I.e., large beta approximate the winner-takes-all function (deterministically choosing the k with value[k*stride]=maximal, small beta the uniform distribution.
float *rnd_frame(int dim, int num):
return num pairwise orthogonal unit vectors of dim dim each, with otherwise random direction. If num<0, num=dim is assumed. If num>dim, only consecutive blocks of dim unit vectors will be pairwise orthogonal.
void rnd_multihedron(float *result):
return sample from uniform distribution in dimof(result)-dimensional multihedron with radius 1 centered at the origin. The "top" of the multihedron is always at (0,0,...0,1).
float *multihedron(int dim)
return corner points of the multihedron for which rnd_multihedron() generates samples. Each corner is a dim dimensional row vector, all dim+1 such vectors are returned concatenated as a single row matrix.
float *multihedron(float *buf)
dito, but uses buf to return the result.
void rnd_sphere(float *result)
return sample from uniform distribution in unit sphere.
float *hypercube(int d)
return matrix with corners of d-dimensional hypercube [0,1]^d as its 2^d rows.
float *hypercube(int i, int d)
return binary representation of i, which is the vector for the i-th corner of the d-dimensional hypercube [0,1]^d (0<= i < 2^d). NOTE: the least significant bit sits in element position 0 of the returned vector, ie., when printing the vector, the binary representation appears as written in reversed order.
float *hypercorner(int d)
return vector of a randomly chosen hypercorner of the d dimensional hypercube [0,1]^d.

CLASSES:

Markov Chains:

markov_chain(float *prob=NULL, int *symbols=NULL)
generate random sequence that is a markov chain. For prob=symbols=NULL the default choice is the 8-state Reber grammar with transition symbols B,T,P,S,X,V,E (start and end states 0 and 7 have been added to the 6 "inner" states 1..6). If prob!=NULL, it must be a square matrix with the i-th row specifying the transition probabilities from state i into the states j=0..numstates-1 (the row entries can be relative probabilities that need not sum to 1, there will be always an automatic, separate normalization for each row). Optionally, array symbols may attach to each transition a transition symbol (i.e., only the entries of symbols whose position matches with non-zero entries in prob will be used).

Methods:

void init(int state)
Set current state of markov chain to state
int next(int *symbol=NULL)
generate next symbol in sequence. When symbol!=NULL, also deposit transition symbol in *symbol.

Special handling of "Absorbing States":

States with transition probability 1 into themselves are "absorbing":

When such a state is met, the next state chosen will be state 0.

Image Sampling:

img_sample(int dx, int dy)
create sampler for image of size dx*dy pixels

Class variables:

int dx,dy
(readonly) image width and height in pixels.
int num
(readonly) current size of sampling set (nr of pixels included)

Class methods:

void init(float *prob, float minprob):
prepare sampling. prob[] is assumed to provide for each image pixel a (not necessarily normalized) probability value (ordered row-wise). The image pixels xy with prob[xy]>minprob will become included in the sampling set and will become sampled with a relative probability of prob[xy]. Return value is the number of pixels that were included in the sampling set.
int sample(int *xy)
fill array xy with randomly sampled coordinate pairs. Return nr of samples.

Mixture of Gaussians:

mog(int dim, float *centers, float *axes)
create mixture of gaussians in dim dimensional space.
The i-th block of dim consecutive elements in array centers is taken as the i-th center; the total number n of mixtures is thus given by n=dimof(centers)/dim. If axes has n*dim*dim elements or more, then it its initial portion is assumed to hold a matrix of dim pairwise orthogonal row vectors of dim elements each. Each row is assumed to specify a principal axis, and the length of the row the standard deviation along that axis. If axes has only n*dim elements, then it is assumed to specify the standard deviations for n axis-diagonal gaussians. If axes has only n elements, then it is assumed to specify n standard deviations for the same number of spherical gaussians.
mog(int dim, float *centers, float stdev)
as before, but all gaussians have the same isotropic standard deviation stdev.

Class variables:

float mog.prob[n] : array defining the relative probabilities for the centers.

Class methods:

void mog.vec(float *sample, int *clusterid=NULL)
deposit k=dimof(sample)/dim random samples consecutively in buf. If clusterid is non-NULL, its maximally k initial elements be filled with the cluster-id's (starting with 0) of the generated samples.
float *.mog.vec(int *clusterid)
generate dimof(clusterid) samples and return them in a newly allocated vector; return their cluster-id's in clusterid. Special case: if clusterid=NULL, return a single sample.
float *.mog.vec(int clusterid)
generate a single sample from cluster clusterid and return newly allocated vector.

FILE

/amnt/loge/users/nistaff02/nistaff/rhaschke/nst7/man/../o.linux//../nstsrc/nst_prog_libs.c