An open API service indexing awesome lists of open source software.

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

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.

![Gaussian Random Fields Plot](plot.png)

## 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.