Skip to content

Commit f67c6ac

Browse files
committed
fix: docs
1 parent f886c7b commit f67c6ac

9 files changed

Lines changed: 82 additions & 59 deletions

File tree

website/content/docs/benchmarks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Drivers (sub-crate paths):
166166

167167
```toml
168168
[dependencies]
169-
stochastic-rs = { version = "2.1", features = ["dual-stream-rng"] }
169+
stochastic-rs = { version = "2.2", features = ["dual-stream-rng"] }
170170
```
171171

172172
Unlocks `stochastic_rs_core::simd_rng_dual::SimdRngDual` (two parallel

website/content/docs/concepts/feature-flags.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ If you depend on a sub-crate directly (recommended for lean builds),
5151
you enable the feature on that sub-crate:
5252

5353
```toml
54-
stochastic-rs-stats = { version = "2.1.0", features = ["openblas"] }
54+
stochastic-rs-stats = { version = "2.2.0", features = ["openblas"] }
5555
```
5656

5757
## Common gotchas

website/content/docs/concepts/process-ext.mdx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,21 @@ ship for FGN / fBM only — see the [add-gpu-sampler SKILL](https://github.com/d
6161

6262
## Construction patterns
6363

64-
Every process exposes:
64+
Every process follows the same canonical `new(args, seed)` constructor
65+
(see the [seeding concept page](/docs/concepts/seeding) for the full
66+
design):
6567

6668
```rust
67-
let p = Foo::<T>::new(/* params */, n, x0, t); // thread-local seed
68-
let p = Foo::<T>::with_seed(/* params */, n, x0, t, 42); // explicit seed
69-
let p = Foo::<T>::from_seed_source(/* params */, n, x0, t, src); // chain seeds
69+
use stochastic_rs::simd_rng::{Deterministic, Unseeded};
70+
71+
let p = Foo::<T, _>::new(/* params */, n, x0, t, Unseeded); // auto-seeded
72+
let p = Foo::<T, _>::new(/* params */, n, x0, t, Deterministic::new(42)); // reproducible
73+
let p = Foo::<T, _>::new(/* params */, n, x0, t, shared_seed_source); // chain seeds
7074
```
7175

72-
Use `with_seed` in tests (so they are deterministic) and `from_seed_source`
73-
when chaining processes (e.g. correlated Brownian factors).
76+
Use `Deterministic` in tests so they replay bit-exactly. Pass a shared
77+
seed source when chaining correlated processes — each `seed.rng()` /
78+
`seed.rng_ext()` call atomically advances the internal counter, so the
79+
streams diverge despite the shared root. `SeedExt::reseed(u64)` swaps a
80+
`Deterministic` source in place to sweep seeds without rebuilding the
81+
process.

website/content/docs/copulas.mdx

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,56 +49,49 @@ crashes in equity returns.
4949
use stochastic_rs::copulas::bivariate::clayton::Clayton;
5050
use stochastic_rs::traits::BivariateExt;
5151

52-
let cop = Clayton::<f64>::with_seed(/* theta */ 2.0, 42);
53-
let n = 10_000;
54-
let (u, v) = cop.sample(n); // both Array1<f64> in [0, 1]
52+
let mut cop = Clayton::new();
53+
cop.set_tau(0.5); // τ ⇒ θ via Kendall inversion
54+
let _ = cop.compute_theta();
55+
let uv = cop.sample_with_seed(10_000, 42)?; // Array2<f64>, shape (10_000, 2)
56+
let (u, v) = (uv.column(0), uv.column(1)); // both in [0, 1]
5557

56-
// Empirical Kendall's τ should be ≈ θ / (θ + 2) = 0.5
57-
let tau_hat = stochastic_rs::stats::tail_index::kendall_tau(u.view(), v.view());
58+
let tau_hat = stochastic_rs::stats::tail_index::kendall_tau(u, v);
5859
println!("τ̂ = {:.3}", tau_hat);
5960
```
6061
</Tab>
6162
<Tab value="Python">
6263
```python
6364
import stochastic_rs as srs
6465

65-
cop = srs.Clayton(theta=2.0, seed=42)
66-
u, v = cop.sample(10_000)
66+
cop = srs.Clayton(theta=2.0)
67+
uv = cop.sample(10_000, seed=42) # shape (10_000, 2)
68+
u, v = uv[:, 0], uv[:, 1]
6769
print("Kendall's tau ≈", srs.kendall_tau(u, v)) # ≈ 0.5
6870
```
6971
</Tab>
7072
</Tabs>
7173

7274
### Gaussian copula — multivariate sampling
7375

74-
<Tabs items={['Rust', 'Python']}>
76+
<Tabs items={['Rust']}>
7577
<Tab value="Rust">
7678
```rust
77-
use stochastic_rs::copulas::multivariate::gaussian::GaussianCopula;
79+
use stochastic_rs::copulas::multivariate::gaussian::GaussianMultivariate;
80+
use stochastic_rs::traits::MultivariateExt;
7881
use ndarray::array;
7982

8083
let corr = array![
8184
[1.0, 0.7, 0.3],
8285
[0.7, 1.0, 0.5],
8386
[0.3, 0.5, 1.0],
8487
];
85-
let cop = GaussianCopula::<f64>::with_seed(corr, 42);
86-
let samples = cop.sample(10_000); // Array2<f64>, shape (10_000, 3)
88+
let cop = GaussianMultivariate::new_with_corr(corr)?;
89+
let samples = cop.sample(10_000)?; // Array2<f64>, shape (10_000, 3)
8790
```
88-
</Tab>
89-
<Tab value="Python">
90-
```python
91-
import stochastic_rs as srs
92-
import numpy as np
9391

94-
corr = np.array([
95-
[1.0, 0.7, 0.3],
96-
[0.7, 1.0, 0.5],
97-
[0.3, 0.5, 1.0],
98-
])
99-
cop = srs.GaussianCopula(corr=corr, seed=42)
100-
samples = cop.sample(10_000) # shape (10_000, 3)
101-
```
92+
> The multivariate Gaussian copula depends on `ndarray-linalg` (the
93+
> `openblas` feature) for the Cholesky factorisation, so it is **not**
94+
> wrapped for Python — use the Rust API directly.
10295
</Tab>
10396
</Tabs>
10497

website/content/docs/distributions.mdx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ distributions**, every one of them with:
5858
<Tab value="Rust">
5959
```rust
6060
use stochastic_rs::distributions::normal::SimdNormal;
61+
use stochastic_rs::simd_rng::Deterministic;
6162
use stochastic_rs::traits::DistributionExt;
6263
use rand_distr::Distribution;
6364

64-
let d = SimdNormal::<f64>::with_seed(/* mean */ 0.0, /* std */ 1.0, 42);
65+
let d = SimdNormal::<f64>::new(/* mean */ 0.0, /* std */ 1.0, &Deterministic::new(42));
6566

6667
// Single sample
6768
let mut rng = rand::thread_rng();
@@ -100,9 +101,10 @@ print(d.pdf(0.0), d.cdf(1.96)) # 0.3989, 0.975
100101
<Tab value="Rust">
101102
```rust
102103
use stochastic_rs::distributions::beta::SimdBeta;
104+
use stochastic_rs::simd_rng::Deterministic;
103105
use stochastic_rs::traits::DistributionExt;
104106

105-
let d = SimdBeta::<f64>::with_seed(/* alpha */ 2.0, /* beta */ 5.0, 42);
107+
let d = SimdBeta::<f64>::new(/* alpha */ 2.0, /* beta */ 5.0, &Deterministic::new(42));
106108
let mut buf = vec![0.0; 1_000];
107109
d.fill_slice_fast(&mut buf);
108110
assert!(buf.iter().all(|&x| x >= 0.0 && x <= 1.0));
@@ -130,8 +132,9 @@ print(d.mean(), d.variance()) # 0.2857, 0.0255
130132
<Tab value="Rust">
131133
```rust
132134
use stochastic_rs::distributions::poisson::SimdPoisson;
135+
use stochastic_rs::simd_rng::Deterministic;
133136

134-
let d = SimdPoisson::<f64>::with_seed(/* lambda */ 4.0, 42);
137+
let d = SimdPoisson::<u32>::new(/* lambda */ 4.0, &Deterministic::new(42));
135138
let mut buf = vec![0_u32; 10_000];
136139
d.fill_slice_fast(&mut buf);
137140

@@ -154,10 +157,20 @@ print(counts.mean(), counts.var()) # both ≈ 4.0
154157

155158
### Construction
156159

160+
Every distribution follows the same `new(args, &seed)` constructor pattern — pass
161+
[`Unseeded`](/docs/concepts/seeding) for an auto-seeded RNG or
162+
[`Deterministic::new(u64)`](/docs/concepts/seeding) for a reproducible
163+
stream. See the [seeding concept page](/docs/concepts/seeding) for the
164+
full design (including `SeedExt::reseed`, the generic `R: SimdRngExt`
165+
backing RNG, and the experimental `dual-stream-rng` feature).
166+
157167
```rust
158-
let d = Foo::<T>::new(/* params */); // thread-local seed
159-
let d = Foo::<T>::with_seed(/* params */, /* seed */ 42); // explicit seed
160-
let d = Foo::<T>::from_seed_source(/* params */, source); // chain seeds
168+
use stochastic_rs::simd_rng::{Deterministic, Unseeded};
169+
170+
let d = Foo::<T>::new(/* params */, &Unseeded); // auto-seeded
171+
let d = Foo::<T>::new(/* params */, &Deterministic::new(42)); // reproducible
172+
let d = Foo::<T>::new(/* params */, &shared_seed_source); // share a seed source
173+
// across sub-components
161174
```
162175

163176
### Sampling

website/content/docs/getting-started/installation-rust.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ status: stable
1212

1313
```toml
1414
[dependencies]
15-
stochastic-rs = "2.1.0"
15+
stochastic-rs = "2.2.0"
1616
```
1717

1818
Then:
@@ -33,13 +33,13 @@ sub-crates you need:
3333

3434
```toml
3535
[dependencies]
36-
stochastic-rs-distributions = "2.1.0" # SIMD distribution sampling
37-
stochastic-rs-stochastic = "2.1.0" # 120+ process types
38-
stochastic-rs-copulas = "2.1.0" # bivariate / multivariate copulas
39-
stochastic-rs-stats = "2.1.0" # estimators
40-
stochastic-rs-quant = "2.1.0" # pricing / calibration / vol surface
41-
stochastic-rs-ai = "2.1.0" # neural surrogates (candle)
42-
stochastic-rs-viz = "2.1.0" # plotly grid plotter
36+
stochastic-rs-distributions = "2.2.0" # SIMD distribution sampling
37+
stochastic-rs-stochastic = "2.2.0" # 120+ process types
38+
stochastic-rs-copulas = "2.2.0" # bivariate / multivariate copulas
39+
stochastic-rs-stats = "2.2.0" # estimators
40+
stochastic-rs-quant = "2.2.0" # pricing / calibration / vol surface
41+
stochastic-rs-ai = "2.2.0" # neural surrogates (candle)
42+
stochastic-rs-viz = "2.2.0" # plotly grid plotter
4343
```
4444

4545
Topology:

website/content/docs/processes.mdx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ $H > 0.5$ is persistent.
9393
<Tabs items={['Rust', 'Python']}>
9494
<Tab value="Rust">
9595
```rust
96+
use stochastic_rs::simd_rng::Deterministic;
9697
use stochastic_rs::stochastic::noise::fgn::Fgn;
9798

98-
let fgn = Fgn::<f64>::with_seed(/* hurst */ 0.3, /* sigma */ 1.0,
99-
/* n */ 4096, /* t */ Some(1.0),
100-
/* seed */ 42);
99+
let fgn = Fgn::<f64, _>::new(/* hurst */ 0.3, /* sigma */ 1.0,
100+
/* n */ 4096, /* t */ Some(1.0),
101+
Deterministic::new(42));
101102
let increments = fgn.sample();
102103
```
103104
</Tab>
@@ -117,17 +118,24 @@ fbm = np.cumsum(increments) # fBM = cumsum(fGN)
117118

118119
### Construction
119120

120-
Every process exposes three constructors:
121+
Every process follows the same `new(args, seed)` pattern (mirrors the
122+
distribution constructors — see the [seeding concept
123+
page](/docs/concepts/seeding)). The seed argument is a value implementing
124+
[`SeedExt`](/docs/concepts/seeding):
121125

122126
```rust
123-
let p = Foo::<T>::new(/* params */, n, x0, t); // thread-local seed
124-
let p = Foo::<T>::with_seed(/* params */, n, x0, t, /* seed */ 42); // explicit seed
125-
let p = Foo::<T>::from_seed_source(/* params */, n, x0, t, source); // chain seeds
127+
use stochastic_rs::simd_rng::{Deterministic, Unseeded};
128+
129+
let p = Foo::<T, _>::new(/* params */, n, x0, t, Unseeded); // auto-seeded
130+
let p = Foo::<T, _>::new(/* params */, n, x0, t, Deterministic::new(42)); // reproducible
126131
```
127132

128-
Use `with_seed` in tests (so they are deterministic) and
129-
`from_seed_source` when chaining processes (e.g. correlated Brownian
130-
factors).
133+
Use `Deterministic` in tests so they replay bit-exactly; pass a shared
134+
`Deterministic` to several processes when chaining correlated factors —
135+
each call to `seed.rng()` / `seed.rng_ext()` atomically advances the
136+
internal counter, so the streams diverge despite the shared root seed.
137+
`SeedExt::reseed(u64)` swaps a `Deterministic` source in place to sweep
138+
seeds without rebuilding the process.
131139

132140
### Sampling
133141

website/content/docs/stats.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ Recommended for empirical roughness studies.
102102
<Tabs items={['Rust', 'Python']}>
103103
<Tab value="Rust">
104104
```rust
105+
use stochastic_rs::simd_rng::Deterministic;
105106
use stochastic_rs::stochastic::noise::fgn::Fgn;
106107
use stochastic_rs::stats::fukasawa_hurst::FukasawaHurst;
107108
use stochastic_rs::traits::ProcessExt;
108109

109110
let true_h = 0.3;
110-
let path = Fgn::<f64>::with_seed(true_h, 1.0, 4096, Some(1.0), 42).sample();
111+
let path = Fgn::<f64, _>::new(true_h, 1.0, 4096, Some(1.0), Deterministic::new(42)).sample();
111112
let res = FukasawaHurst::<f64>::new().estimate(path.view());
112113

113114
println!("H̃ = {:.3} (true = {:.3})", res.point, true_h);

website/content/docs/viz.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ build does not pull Plotly's transitive deps.
1818

1919
```toml
2020
[dependencies]
21-
stochastic-rs-viz = "2.1.0"
21+
stochastic-rs-viz = "2.2.0"
2222
# or via the umbrella:
23-
stochastic-rs = { version = "2.1.0", features = ["viz"] }
23+
stochastic-rs = { version = "2.2.0", features = ["viz"] }
2424
```
2525

2626
## Examples

0 commit comments

Comments
 (0)