Rather than simply a block of Rust code that returns a bool, we could additionally support a "distribution" object.
I'm thinking along the lines of a trait that could implement:
-
fn membership(val: &T) -> bool (this is a special case of fn log_prob(&T) -> Option<f64>) to check whether a value is part of the distribution. I.e. the same functionality as the current requires & ensures clause.
-
fn sample(ent: f64) -> T to generate a value in the distribution from an entropy source ranging from 0.0 to 1.0. This could then be connected to a QMC sampler.
Not all data types exist in a space that's easy to sample from, so this isn't a universal solution. But when it works it can provide more super-powers.
Rather than simply a block of Rust code that returns a
bool, we could additionally support a "distribution" object.I'm thinking along the lines of a trait that could implement:
fn membership(val: &T) -> bool(this is a special case offn log_prob(&T) -> Option<f64>) to check whether a value is part of the distribution. I.e. the same functionality as the currentrequires&ensuresclause.fn sample(ent: f64) -> Tto generate a value in the distribution from an entropy source ranging from 0.0 to 1.0. This could then be connected to a QMC sampler.Not all data types exist in a space that's easy to sample from, so this isn't a universal solution. But when it works it can provide more super-powers.