https://github.com/axect/grf_test
Generate Gaussian Random Fields
https://github.com/axect/grf_test
Last synced: 4 months ago
JSON representation
Generate Gaussian Random Fields
- Host: GitHub
- URL: https://github.com/axect/grf_test
- Owner: Axect
- Created: 2023-02-06T02:57:09.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-18T07:27:13.000Z (almost 2 years ago)
- Last Synced: 2025-10-04T19:55:43.443Z (4 months ago)
- Language: Rust
- Size: 458 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gaussian Random Fields (GRF) Generator
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.
## Requirements
- Rust programming language
- rustfft library
- peroxide library
## Usage
To run the program, use the following command:
```bash
cargo run --
```
- ``: The number of samples to generate.
- ``: The number of nodes in each sample.
- ``: The kernel window size.
## Example
Here's an example command to generate 4 samples with 100 nodes each and a kernel window size of 0.1:
```bash
cargo run --release -- 4 100 0.1
```
## Output
The program generates a plot of the Gaussian Random Fields and saves it as `plot.png` in the current directory.

## Implementation Details
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:
1. Generate the x-coordinates using the `linspace` function.
2. For each sample, call the `grf` function to calculate the GRF values.
3. Generate line styles and colors for each sample.
4. Create a `Plot2D` object and insert the GRF values as images.
5. Set the plot properties such as line styles, colors, labels, and style.
6. 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.
## References
- Chan, Grace., _An Effective Method for Simulating Gaussian Random Fields_, Proceedings of the statistical Computing section. 1999.