File Exchange

image thumbnail

Random Field Simulation

version 1.5 (6.52 KB) by

Generate multivariate conditional random fields given a mesh and covariance information.



View License

Given a list of d-dimensional points -- typically, though not necessarily, representing a mesh -- and correlation information, the function randomfield.m returns realizations of a corresponding random process. These fields may be conditioned on known data values.

The correlation information can be:
- one of three parameterized models,
- a given correlation matrix with dimensions corresponding to the number of mesh points,
- a matrix of "snapshots" of an unknown process.

The function can also return a struct with the Karhunen-Loeve bases for further field generation and filtering. See the options described in the help for more details.

When data is given for the field realizations to interpolate, the returned mean is the ordinary kriging approximation.

If you have the parallel computing toolbox and more than one core, this will go faster.

Copyright Paul G. Constantine and Qiqi Wang.

Comments and Ratings (14)

Does anyone know how to test this file? I have no idea about input parameters. Many thanks in advance.


Very good, thanks for sharing. Now I'm investigating the behavior of concrete, a typical heterogeneous material, and intend to use this program to generate the random filed.

Jeremy Maurer

Works very well and easy to implement.

Really useful, thanks a lot!! just one thing, the default value for spthresh is set to 0.01, shouldn't it be set to 0 ?


Thanks very much. Now I do the project related the 2d random field simulation involving K-L expansion

Hi Paul, nice code.

I tried to generate a random field with correlation length 0.2, and sigma value of 0.03 (Gaussian correlation). I varied the mesh size by 100 and 500, and I obtained different realization with similar parameters (including the weights). Is the random field sensitive to the mesh size?


Chao Zhuang

It's very helpful. Thanks!


Thanks very much

nacim Debabi

nice trick

Just fixed a few bugs. It should respect the data points now.



João (view profile)



Learned to use zip.


Latest version incorporates a low-memory option for large meshes. However, it is slow.

Performance is substantially improved when using the Parallel Computing Toolbox. The scripts use parfor to construct the correlation matrix.


Fixed a bug when computing the covariance matrix from snapshots.

MATLAB Release
MATLAB 7.13 (R2011b)

Inspired: PMPack - Parameterized Matrix Package

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video