Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ members = [
"stochastic-rs-py",
]

[workspace.package]
version = "2.1.0"

[workspace.dependencies]
# Internal crates
stochastic-rs-core = { path = "stochastic-rs-core", version = "2.0.0" }
stochastic-rs-distributions = { path = "stochastic-rs-distributions", version = "2.0.0" }
stochastic-rs-stochastic = { path = "stochastic-rs-stochastic", version = "2.0.0" }
stochastic-rs-copulas = { path = "stochastic-rs-copulas", version = "2.0.0" }
stochastic-rs-stats = { path = "stochastic-rs-stats", version = "2.0.0" }
stochastic-rs-quant = { path = "stochastic-rs-quant", version = "2.0.0" }
stochastic-rs-ai = { path = "stochastic-rs-ai", version = "2.0.0" }
stochastic-rs-viz = { path = "stochastic-rs-viz", version = "2.0.0" }
stochastic-rs-core = { path = "stochastic-rs-core", version = "2.1" }
stochastic-rs-distributions = { path = "stochastic-rs-distributions", version = "2.1" }
stochastic-rs-stochastic = { path = "stochastic-rs-stochastic", version = "2.1" }
stochastic-rs-copulas = { path = "stochastic-rs-copulas", version = "2.1" }
stochastic-rs-stats = { path = "stochastic-rs-stats", version = "2.1" }
stochastic-rs-quant = { path = "stochastic-rs-quant", version = "2.1" }
stochastic-rs-ai = { path = "stochastic-rs-ai", version = "2.1" }
stochastic-rs-viz = { path = "stochastic-rs-viz", version = "2.1" }

# Math / numerical core
ndarray = { version = "0.17.2", features = ["rayon", "matrixmultiply-threading"] }
Expand Down Expand Up @@ -107,7 +110,7 @@ criterion = { version = "0.8", features = ["html_reports"] }

[package]
name = "stochastic-rs"
version = "2.0.0"
version.workspace = true
edition = "2024"
license = "MIT"
description = "A Rust library for quant finance and simulating stochastic processes."
Expand Down
5 changes: 3 additions & 2 deletions benches/fgn_accelerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::noise::fgn::Fgn;
use stochastic_rs::traits::ProcessExt;

Expand All @@ -15,7 +16,7 @@ fn bench_single(c: &mut Criterion) {
g.sample_size(40);

for &n in &[1024usize, 4096, 16384, 65536] {
let fgn = Fgn::new(0.7f32, n, None);
let fgn = Fgn::new(0.7f32, n, None, Unseeded);
let _ = fgn.sample_accelerate(1);

g.bench_with_input(BenchmarkId::new("cpu", n), &n, |b, _| {
Expand All @@ -42,7 +43,7 @@ fn bench_batch(c: &mut Criterion) {
(16384, 512),
];
for &(n, m) in &cases {
let fgn = Fgn::new(0.7f32, n, None);
let fgn = Fgn::new(0.7f32, n, None, Unseeded);
let _ = fgn.sample_accelerate(m);
let label = format!("n={n},m={m}");

Expand Down
5 changes: 3 additions & 2 deletions benches/fgn_all_backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::noise::fgn::Fgn;
use stochastic_rs::traits::ProcessExt;

Expand All @@ -15,7 +16,7 @@ fn bench_single(c: &mut Criterion) {
g.sample_size(40);

for &n in &[1024usize, 4096, 16384, 65536] {
let fgn = Fgn::new(0.7f32, n, None);
let fgn = Fgn::new(0.7f32, n, None, Unseeded);

// warmup
let _ = fgn.sample_gpu(1);
Expand Down Expand Up @@ -52,7 +53,7 @@ fn bench_batch(c: &mut Criterion) {
(16384, 512),
];
for &(n, m) in &cases {
let fgn = Fgn::new(0.7f32, n, None);
let fgn = Fgn::new(0.7f32, n, None, Unseeded);
let _ = fgn.sample_gpu(m);
let _ = fgn.sample_metal(m);
let _ = fgn.sample_accelerate(m);
Expand Down
5 changes: 3 additions & 2 deletions benches/fgn_cuda_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::noise::fgn::Fgn;
use stochastic_rs::traits::ProcessExt;

Expand All @@ -17,7 +18,7 @@ fn bench_fgn_single_path_cpu_vs_cuda_native(c: &mut Criterion) {
let hurst = 0.7f32;

for &n in &[1024usize, 4096, 16384, 65536] {
let fgn = Fgn::new(hurst, n, None);
let fgn = Fgn::new(hurst, n, None, Unseeded);

let _ = fgn
.sample_cuda_native(1)
Expand Down Expand Up @@ -65,7 +66,7 @@ fn bench_fgn_batch_cpu_vs_cuda_native(c: &mut Criterion) {

for &(n, m) in &cases {
let label = format!("n={n},m={m}");
let fgn = Fgn::new(hurst, n, None);
let fgn = Fgn::new(hurst, n, None, Unseeded);

let _ = fgn
.sample_cuda_native(m)
Expand Down
19 changes: 10 additions & 9 deletions benches/fgn_fbm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::noise::fgn::Fgn;
use stochastic_rs::stochastic::process::fbm::Fbm;
use stochastic_rs::traits::ProcessExt;
Expand All @@ -14,7 +15,7 @@ fn bench_fgn_by_size(c: &mut Criterion) {

for &n in &[256, 1024, 4096, 16384, 65536] {
group.bench_with_input(BenchmarkId::new("ndrustfft", n), &n, |b, &n| {
let fgn = Fgn::new(hurst, n, None);
let fgn = Fgn::new(hurst, n, None, Unseeded);
b.iter(|| black_box(fgn.sample()));
});
}
Expand All @@ -30,7 +31,7 @@ fn bench_fgn_by_hurst(c: &mut Criterion) {
let label = format!("H={:.1}", h);

group.bench_with_input(BenchmarkId::new("ndrustfft", &label), &h, |b, &h| {
let fgn = Fgn::new(h, n, None);
let fgn = Fgn::new(h, n, None, Unseeded);
b.iter(|| black_box(fgn.sample()));
});
}
Expand All @@ -45,12 +46,12 @@ fn bench_fgn_f32_vs_f64(c: &mut Criterion) {
let hurst_f32 = 0.7f32;

group.bench_function("f64/ndrustfft", |b| {
let fgn = Fgn::new(hurst_f64, n, None);
let fgn = Fgn::new(hurst_f64, n, None, Unseeded);
b.iter(|| black_box(fgn.sample()));
});

group.bench_function("f32/ndrustfft", |b| {
let fgn = Fgn::new(hurst_f32, n, None);
let fgn = Fgn::new(hurst_f32, n, None, Unseeded);
b.iter(|| black_box(fgn.sample()));
});

Expand All @@ -64,12 +65,12 @@ fn bench_fgn_sample_par(c: &mut Criterion) {

for &m in &[10, 100, 1000] {
group.bench_with_input(BenchmarkId::new("sample_par", m), &m, |b, &m| {
let fgn = Fgn::new(hurst, n, None);
let fgn = Fgn::new(hurst, n, None, Unseeded);
b.iter(|| black_box(fgn.sample_par(m)));
});

group.bench_with_input(BenchmarkId::new("sample_sequential", m), &m, |b, &m| {
let fgn = Fgn::new(hurst, n, None);
let fgn = Fgn::new(hurst, n, None, Unseeded);
b.iter(|| {
let v: Vec<_> = (0..m).map(|_| fgn.sample()).collect();
black_box(v)
Expand All @@ -86,7 +87,7 @@ fn bench_fbm_by_size(c: &mut Criterion) {

for &n in &[256, 1024, 4096, 16384, 65536] {
group.bench_with_input(BenchmarkId::new("sample", n), &n, |b, &n| {
let fbm = Fbm::new(hurst, n, None);
let fbm = Fbm::new(hurst, n, None, Unseeded);
b.iter(|| black_box(fbm.sample()));
});
}
Expand All @@ -101,12 +102,12 @@ fn bench_fbm_sample_par(c: &mut Criterion) {

for &m in &[10, 100, 1000] {
group.bench_with_input(BenchmarkId::new("sample_par", m), &m, |b, &m| {
let fbm = Fbm::new(hurst, n, None);
let fbm = Fbm::new(hurst, n, None, Unseeded);
b.iter(|| black_box(fbm.sample_par(m)));
});

group.bench_with_input(BenchmarkId::new("sample_sequential", m), &m, |b, &m| {
let fbm = Fbm::new(hurst, n, None);
let fbm = Fbm::new(hurst, n, None, Unseeded);
b.iter(|| {
let v: Vec<_> = (0..m).map(|_| fbm.sample()).collect();
black_box(v)
Expand Down
5 changes: 3 additions & 2 deletions benches/fgn_gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::noise::fgn::Fgn;
use stochastic_rs::traits::ProcessExt;

Expand All @@ -17,7 +18,7 @@ fn bench_fgn_single_path_cpu_vs_gpu(c: &mut Criterion) {
let hurst = 0.7f32;

for &n in &[1024usize, 4096, 16384, 65536] {
let fgn = Fgn::new(hurst, n, None);
let fgn = Fgn::new(hurst, n, None, Unseeded);

let _ = fgn
.sample_gpu(1)
Expand Down Expand Up @@ -58,7 +59,7 @@ fn bench_fgn_batch_cpu_vs_gpu(c: &mut Criterion) {

for &(n, m) in &cases {
let label = format!("n={n},m={m}");
let fgn = Fgn::new(hurst, n, None);
let fgn = Fgn::new(hurst, n, None, Unseeded);

let _ = fgn.sample_gpu(m).expect("GPU batch warmup should succeed");

Expand Down
5 changes: 3 additions & 2 deletions benches/fgn_metal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::noise::fgn::Fgn;
use stochastic_rs::traits::ProcessExt;

Expand All @@ -15,7 +16,7 @@ fn bench_single(c: &mut Criterion) {
g.sample_size(40);

for &n in &[1024usize, 4096, 16384, 65536] {
let fgn = Fgn::new(0.7f32, n, None);
let fgn = Fgn::new(0.7f32, n, None, Unseeded);
let _ = fgn.sample_metal(1);

g.bench_with_input(BenchmarkId::new("cpu", n), &n, |b, _| {
Expand All @@ -42,7 +43,7 @@ fn bench_batch(c: &mut Criterion) {
(16384, 512),
];
for &(n, m) in &cases {
let fgn = Fgn::new(0.7f32, n, None);
let fgn = Fgn::new(0.7f32, n, None, Unseeded);
let _ = fgn.sample_metal(m);
let label = format!("n={n},m={m}");

Expand Down
29 changes: 21 additions & 8 deletions benches/gn_batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use ndarray::Array1;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::diffusion::fouque::FouqueOU2D;
use stochastic_rs::stochastic::interest::hjm::Hjm;
use stochastic_rs::stochastic::interest::wu_zhang::WuZhangD;
Expand All @@ -21,12 +22,12 @@ fn bench_cgns(c: &mut Criterion) {
let rho = 0.6f64;

group.bench_with_input(BenchmarkId::new("new", n), &n, |b, &n| {
let proc = Cgns::<f64>::new(rho, n, Some(1.0));
let proc = Cgns::<f64, _>::new(rho, n, Some(1.0), Unseeded);
b.iter(|| black_box(proc.sample()));
});

group.bench_with_input(BenchmarkId::new("old_style", n), &n, |b, &n| {
let gn = Gn::<f64>::new(n, Some(1.0));
let gn = Gn::<f64, _>::new(n, Some(1.0), Unseeded);
b.iter(|| {
let gn1 = gn.sample();
let z = gn.sample();
Expand All @@ -49,12 +50,22 @@ fn bench_fouque(c: &mut Criterion) {
let n = 100_000usize;

group.bench_with_input(BenchmarkId::new("new", n), &n, |b, &n| {
let proc = FouqueOU2D::<f64>::new(1.0, 0.5, 0.1, 0.0, n, Some(0.0), Some(0.0), Some(1.0));
let proc = FouqueOU2D::<f64, _>::new(
1.0,
0.5,
0.1,
0.0,
n,
Some(0.0),
Some(0.0),
Some(1.0),
Unseeded,
);
b.iter(|| black_box(proc.sample()));
});

group.bench_with_input(BenchmarkId::new("old_style", n), &n, |b, &n| {
let gn = Gn::<f64>::new(n - 1, Some(1.0));
let gn = Gn::<f64, _>::new(n - 1, Some(1.0), Unseeded);
let dt = gn.dt();
b.iter(|| {
let gn_x = gn.sample();
Expand Down Expand Up @@ -105,7 +116,7 @@ fn bench_hjm(c: &mut Criterion) {
let t_max = 1.0f64;

group.bench_with_input(BenchmarkId::new("new", n), &n, |b, &n| {
let proc = Hjm::<f64>::new(
let proc = Hjm::<f64, _>::new(
a_fn as fn(f64) -> f64,
b_fn as fn(f64) -> f64,
p_fn as fn(f64, f64) -> f64,
Expand All @@ -118,12 +129,13 @@ fn bench_hjm(c: &mut Criterion) {
Some(1.0),
Some(0.02),
Some(t_max),
Unseeded,
);
b.iter(|| black_box(proc.sample()));
});

group.bench_with_input(BenchmarkId::new("old_style", n), &n, |b, &n| {
let gn = Gn::<f64>::new(n - 1, Some(t_max));
let gn = Gn::<f64, _>::new(n - 1, Some(t_max), Unseeded);
let dt = gn.dt();
b.iter(|| {
let mut r = Array1::<f64>::zeros(n);
Expand Down Expand Up @@ -165,7 +177,7 @@ fn bench_wuzhang(c: &mut Criterion) {
let v0 = Array1::from_elem(xn, 0.04f64);

group.bench_with_input(BenchmarkId::new("new", n), &n, |b, &_n| {
let proc = WuZhangD::<f64>::new(
let proc = WuZhangD::<f64, _>::new(
alpha.clone(),
beta.clone(),
nu.clone(),
Expand All @@ -175,12 +187,13 @@ fn bench_wuzhang(c: &mut Criterion) {
xn,
Some(1.0),
n,
Unseeded,
);
b.iter(|| black_box(proc.sample()));
});

group.bench_with_input(BenchmarkId::new("old_style", n), &n, |b, &_n| {
let gn = Gn::<f64>::new(n - 1, Some(1.0));
let gn = Gn::<f64, _>::new(n - 1, Some(1.0), Unseeded);
let dt = gn.dt();
b.iter(|| {
let mut fv = ndarray::Array2::<f64>::zeros((2 * xn, n));
Expand Down
Loading
Loading