| | |
-
- RandomStructure
class RandomStructure() |
| |
Class to create randomized data structures other than single random
variates from various distributions. It relies heavily on the the
random stream generator classes but do not inherit from them. It
needs at least one random stream as an input. This is the way to
trigger the RandomStructure class:
from genrandstrm import GeneralRandomStream
from randstruct import RandomStructure
rstream = GeneralRandomStream()
rstruct = RandomStructure(rstream)
or, if two streams are needed:
rstream1 = GeneralRandomStream()
rstream2 = GeneralRandomStream(different_nseed)
rstruct = RandomStructure(rstream1, rstream2)
A couple of the methods of this class may be used in a way that creates
streams of uniformly distributed random numbers in [0.0, 1.0] that may
be fed into an instance object punched out with InverseRandomStream -
the latter may then use this stream instead of repeated sampling via
the basic random number generator, cf. the docstring documentation of
InverseRandomStream! |
| |
Methods defined here:
- __init__(self, rstream, rstream2=None)
- Inputs are GeneralRandomStream instance objects. Makes it possible
to use two streams of random variates.
- antithet_sample(self, nparams)
- Generates a matrix having two rows, the first row being a list of
uniformly distributed random numbers p in [0.0, 1.0], each row
containing nparams elements. The second row contains the corresponding
antithetic sample with the complements 1-p.
- bootindexvector(self, vector)
- Returns a list of indices of a full bootstrap sample
from the input vector (a list or tuple).
- bootvector(self, vector)
- Returns a full bootstrap sample from the input vector (a list or tuple).
- lhs_sample(self, nparams, nintervals, rcorrmatrix=None, checklevel=0)
- Generates a full Latin Hypercube Sample of uniformly distributed
random variates in [0.0, 1.0] placed in a matrix with one realization
in each row. A target rank correlation matrix can be given (must have
the dimension nsamples*nsamples).
checklevel may be 0, 1 or 2 and is used to control trace printout.
0 produces no trace output, whereas 2 produces the most.
NB. IN ORDER FOR LATIN HYPERCUBE SAMPLING TO BE MEANINGFUL THE OUTPUT
STREAM OF RANDOM VARIATES MUST BE HANDLED BY INVERSE METHODS !!!!
Latin Hypercube Sampling was first described by McKay, Conover &
Beckman in a Technometrics article 1979. The use of the LHS technique
to introduce rank correlations was first described by Iman & Conover
1982 in an issue of Communications of Statistics.
- multinormalvector(self, mumx, covarlomx, flat=False)
- Generates a sample from a multinomial normal distribution.
mumx contains the means of each variate and covarlomx is assumed
to be a matrix belonging to the misclib.Matrix class. mumx must
be a column vector and covarlomx the lower triangular matrix from
a previous Cholesky decomposition of the covariance matrix. The
output vector is also on Matrix form, it is a column vector,
unless the user wants it flattened to a list.
- scramble_range(self, nrange, stream, scores=False)
- Returns a list containing a random permutation of integers
"in range(nrange)", i. e. in [0, nrange-1]. Van der Waerden
normal scores are also returned if so requested.
An input random stream is made an argument in order for
the method to be able to use any of the two random streams
defined for the class.
- sercorrnormvector(self, n, rho, mu=0.0, sigma=1.0)
- Generates a list of serially correlated normal random
variates. Requires that the rstream object is punched
out from the GeneralRandomStream class!
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |