Skip to content

feat: add Rust-backed discrete convolution for random variables#40

Merged
MthwRobinson merged 6 commits into
mainfrom
feat/conv-rust
Mar 27, 2026
Merged

feat: add Rust-backed discrete convolution for random variables#40
MthwRobinson merged 6 commits into
mainfrom
feat/conv-rust

Conversation

@MthwRobinson

Copy link
Copy Markdown
Owner

Description

This PR adds discrete convolution support to the Rust random variable algebra layer and connects it to the Python API.

The Rust changes introduce a convolution_discrete implementation that converts inputs to PDFs, computes pairwise support sums and probabilities, sorts the result, and merges duplicate support values into a
valid discrete PDF. RandomVariable now supports Add and AddAssign, and the new convolution operation is exported through the Python bindings.

On the Python side, discrete calls to applpy.algebra.convolution now delegate to the Rust-backed FastRV path instead of performing the full computation in Python. This preserves the existing API while
moving the heavy discrete convolution logic into Rust. The PR also adds Rust coverage for the new behavior, including duplicate support aggregation, CDF-to-PDF conversion, and preservation of discrete PDF
metadata.

Testing

Validate the Rust changes:

  • make cargo-check
  • make cargo-test

Validate the Python integration:

  • make check
  • make rust-develop
  • make test

@MthwRobinson MthwRobinson merged commit 615348c into main Mar 27, 2026
6 checks passed
@MthwRobinson MthwRobinson deleted the feat/conv-rust branch March 27, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant