rft1d.random¶
Functions and classes for generating 1D random fields. The functions randn1d and multirandn1d are similar to the numpy.random.randn and np.random.multivariate_normal functions. If a large number of random fields are required (e.g. for RFT validations) it may be more efficient to use the Generator1D and GeneratorMulti1D classes.
randn1d¶
- rft1d.random.randn1d(nResponses, nodes, FWHM=10.0, pad=False)¶
Generate smooth Gaussian random fields.
- Parameters:
nResponses – number of fields (int)
nodes – number of field nodes (int) OR a binary field (boolean array)
FWHM – field smoothness (float)
pad – pad prior to smoothing (bool)
- Returns:
A 2D numpy array with shape: (nResponses, nodes)
- Examples:
>>> y = rft1d.random.randn1d(8, 101, 15.0) >>> y = rft1d.random.randn1d(1000, 101, 75.0, pad=True)
Warning
Padding is slow but necessary when 2 FWHM > nodes
multirandn1d¶
- rft1d.random.multirandn1d(nResponses, nodes, nComponents, FWHM=10.0, W=None, pad=False)¶
Generate smooth Gaussian multivariate random fields.
- Parameters:
nResponses – number of fields (int)
nodes – number of field nodes (int) OR a binary field (boolean array)
nComponents – number of vector components (int)
FWHM – field smoothness (float)
W – covariance matrix (nComponents x nComponents array)
pad – pad prior to smoothing (bool)
- Returns:
A 3D numpy array with shape: (nResponses, nodes, nComponents)
- Notes:
The default W is the identity matrix.
Padding is slow but necessary when 2 FWHM > nodes
- Examples:
>>> y = rft1d.random.multirandn1d(8, 101, 3, 15.0) >>> y = rft1d.random.multirandn1d(1000, 101, 5, 65.0, W=np.eye(5), pad=True)
Generator1D¶
- class rft1d.random.Generator1D(nResponses=1, nodes=101, FWHM=10, pad=False)¶
Generator of smooth Gaussian random fields.
- Parameters:
nResponses – number of fields (int)
nodes – number of field nodes (int) OR a binary field (boolean array)
FWHM – field smoothness (float)
pad – pad prior to smoothing (bool)
- Returns:
A Generator1D object
- Notes:
Generator1D is faster than randn1d for iteratively generating many random samples.
- Examples:
>>> g = rft1d.random.Generator1D(8, 101, 15.0) >>> y = g.generate_sample()
GeneratorMulti1D¶
- class rft1d.random.GeneratorMulti1D(nResponses=1, nodes=101, nComponents=2, FWHM=10, W=None, pad=False)¶
Generator of smooth multivariate Gaussian random fields.
- Parameters:
nResponses – number of fields (int)
nodes – number of field nodes (int) OR a binary field (boolean array)
nComponents – number of vector components (int)
FWHM – field smoothness (float)
W – covariance matrix (nComponents x nComponents array)
pad – pad prior to smoothing (bool)
- Returns:
A GeneratorMulti1D object
- Notes:
GeneratorMulti1D is faster than multirandn1d for iteratively generating many random samples.
- Examples:
>>> g = rft1d.random.GeneratorMulti1D(8, 101, 3, 15.0) >>> y = g.generate_sample()