Metadata-Version: 2.1
Name: random-processes
Version: 0.1.0
Summary: Python library for generating random processes with specified autocorrelation properties. Supports custom kernels and multivariate correlated noise.
Author-email: Alexander Abramov <extremal.ru@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/avabr/random-processes
Project-URL: Repository, https://github.com/avabr/random-processes
Project-URL: Issues, https://github.com/avabr/random-processes/issues
Keywords: random-process,colored-noise,autocorrelation,stochastic,signal-processing,spectral-method
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: matplotlib

# random-processes

Generate random processes with specified autocorrelation properties.

## Quick start

**Exponential:** `R(tau) = D * exp(-lambda * |tau|)`

```python
from random_processes import generate, exponential_kernel

k = exponential_kernel(D=1.0, lam=2.0)
t, x = generate(k, duration=100.0, dt=0.01, seed=42)
```

**Oscillating:** `R(tau) = D * exp(-lambda * |tau|) * cos(w0 * tau)`

```python
from random_processes import generate, oscillating_kernel

k = oscillating_kernel(D=2.0, lam=0.5, w0=10.0)
t, x = generate(k, duration=200.0, dt=0.005, seed=42)
```

**Custom kernel:**

```python
import numpy as np
from random_processes import generate, AutocorrKernel

k = AutocorrKernel(func=lambda tau: np.exp(-tau**2), name="gaussian")
t, x = generate(k, duration=50.0, dt=0.01, seed=7)
```



![Exponential kernel](figures/exponential.png)



![Oscillating kernel](figures/oscillating.png)

## Multivariate correlated noise

```python
import numpy as np
from random_processes import generate, exponential_kernel, oscillating_kernel

kernels = [exponential_kernel(D=1.0, lam=2.0), oscillating_kernel(D=0.5, lam=1.0, w0=3.0)]
corr = np.array([[1.0, 0.7],
                 [0.7, 1.0]])
t, X = generate(kernels, corr=corr, duration=100.0, dt=0.01, seed=42)
# X.shape == (2, 10000)
```

## Visualization

```python
from random_processes.visualization import plot_realization, plot_correlation
import matplotlib.pyplot as plt

fig, axes = plt.subplots(2, 1, figsize=(10, 6))
plot_realization(t, x, ax=axes[0])
plot_correlation(t, x, k, ax=axes[1])
plt.tight_layout()
plt.show()
```

## Testing

Confidence bands use Fisher z-transform with effective sample size to account for correlation in the data. This is an approximation (exact intervals require Bartlett's formula), but sufficient for validation purposes.

Scalar (with plots / without):
```bash
python -c "from random_processes.testing import run_test_suite; run_test_suite()"
python -c "from random_processes.testing import run_test_suite; run_test_suite(show_plots=False)"
```

Multivariate (with plots / without):
```bash
python -c "from random_processes.testing import run_multi_test_suite; run_multi_test_suite()"
python -c "from random_processes.testing import run_multi_test_suite; run_multi_test_suite(show_plots=False)"
```

## Requirements

- Python >= 3.10
- numpy
- scipy
- matplotlib (for visualization)
