This Rust program generates Gaussian Random Fields (GRF) using the circulant embedding method. It allows you to specify the number of samples, nodes, and the kernel window size. The generated GRF is then plotted and saved as an image file.
- Rust programming language
- rustfft library
- peroxide library
To run the program, use the following command:
cargo run -- <num_samples> <num_nodes> <sigma><num_samples>: The number of samples to generate.<num_nodes>: The number of nodes in each sample.<sigma>: The kernel window size.
Here's an example command to generate 4 samples with 100 nodes each and a kernel window size of 0.1:
cargo run --release -- 4 100 0.1The program generates a plot of the Gaussian Random Fields and saves it as plot.png in the current directory.
The program uses the circulant embedding method to generate Gaussian Random Fields efficiently. It leverages the Fast Fourier Transform (FFT) from the rustfft library to speed up the computations.
The main steps of the algorithm are:
- Generate the x-coordinates using the
linspacefunction. - For each sample, call the
grffunction to calculate the GRF values. - Generate line styles and colors for each sample.
- Create a
Plot2Dobject and insert the GRF values as images. - Set the plot properties such as line styles, colors, labels, and style.
- Save the plot as
plot.png.
The grf function implements the circulant embedding method to generate the GRF values. It uses the Stationary Gaussian Kernel defined by the k function.
- Chan, Grace., An Effective Method for Simulating Gaussian Random Fields, Proceedings of the statistical Computing section. 1999.
