Skip to main content

ActiveDesignResult

Struct ActiveDesignResult 

Source
pub struct ActiveDesignResult { /* private fields */ }
Expand description

Result of a sequential active Bayesian-quadrature run.

Implementations§

Source§

impl ActiveDesignResult

Source

pub fn nodes(&self) -> &[f64]

Final observation nodes, including actively selected points.

Source

pub fn values(&self) -> &[f64]

Final observed function values.

Source

pub fn remaining_candidates(&self) -> &[f64]

Candidates not selected during this run.

Source

pub fn steps(&self) -> &[ActiveDesignStep]

Ordered active-evaluation history.

Examples found in repository?
examples/active_quadrature.rs (line 39)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16    let kernel = RbfKernel::new(1.0, 1.0)?;
17    let measure = GaussianMeasure::new(0.0, 1.0)?;
18    let quadrature = BayesianQuadrature::new(kernel, measure, 1.0e-10);
19    let active = ActiveBayesianQuadrature::new(quadrature);
20
21    // Start from three evaluations; allow up to six more from a fixed candidate grid,
22    // stopping early once the posterior variance of the integral drops below 1e-6.
23    let initial_nodes = [-1.0, 0.0, 1.0];
24    let initial_values: Vec<f64> = initial_nodes.iter().copied().map(integrand).collect();
25    let candidates: Vec<f64> = (0..=23).map(|i| -2.875 + 0.25 * f64::from(i)).collect();
26
27    let initial = quadrature.posterior(&initial_nodes, &initial_values)?;
28    println!("initial posterior variance = {:.3e}", initial.variance());
29
30    let result = active.run(
31        &initial_nodes,
32        &initial_values,
33        &candidates,
34        6,
35        1.0e-6,
36        integrand,
37    )?;
38
39    for step in result.steps() {
40        println!(
41            "x = {:+.3}  predicted reduction = {:.3e}  posterior variance = {:.3e}",
42            step.point(),
43            step.predicted_variance_reduction(),
44            step.posterior_variance(),
45        );
46    }
47
48    let exact = (1.0_f64 / 3.0).sqrt() * (-0.25_f64 / 3.0).exp();
49    let posterior = result.posterior();
50    println!("stopped because: {:?}", result.termination());
51    println!(
52        "E[I | y] = {:.6} ± {:.3e}   (exact {exact:.6})",
53        posterior.mean(),
54        posterior.standard_deviation(),
55    );
56    Ok(())
57}
Source

pub const fn posterior(&self) -> ScalarNormalPosterior

Final integral posterior.

Examples found in repository?
examples/active_quadrature.rs (line 49)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16    let kernel = RbfKernel::new(1.0, 1.0)?;
17    let measure = GaussianMeasure::new(0.0, 1.0)?;
18    let quadrature = BayesianQuadrature::new(kernel, measure, 1.0e-10);
19    let active = ActiveBayesianQuadrature::new(quadrature);
20
21    // Start from three evaluations; allow up to six more from a fixed candidate grid,
22    // stopping early once the posterior variance of the integral drops below 1e-6.
23    let initial_nodes = [-1.0, 0.0, 1.0];
24    let initial_values: Vec<f64> = initial_nodes.iter().copied().map(integrand).collect();
25    let candidates: Vec<f64> = (0..=23).map(|i| -2.875 + 0.25 * f64::from(i)).collect();
26
27    let initial = quadrature.posterior(&initial_nodes, &initial_values)?;
28    println!("initial posterior variance = {:.3e}", initial.variance());
29
30    let result = active.run(
31        &initial_nodes,
32        &initial_values,
33        &candidates,
34        6,
35        1.0e-6,
36        integrand,
37    )?;
38
39    for step in result.steps() {
40        println!(
41            "x = {:+.3}  predicted reduction = {:.3e}  posterior variance = {:.3e}",
42            step.point(),
43            step.predicted_variance_reduction(),
44            step.posterior_variance(),
45        );
46    }
47
48    let exact = (1.0_f64 / 3.0).sqrt() * (-0.25_f64 / 3.0).exp();
49    let posterior = result.posterior();
50    println!("stopped because: {:?}", result.termination());
51    println!(
52        "E[I | y] = {:.6} ± {:.3e}   (exact {exact:.6})",
53        posterior.mean(),
54        posterior.standard_deviation(),
55    );
56    Ok(())
57}
Source

pub const fn termination(&self) -> ActiveTermination

Reason the active design stopped.

Examples found in repository?
examples/active_quadrature.rs (line 50)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16    let kernel = RbfKernel::new(1.0, 1.0)?;
17    let measure = GaussianMeasure::new(0.0, 1.0)?;
18    let quadrature = BayesianQuadrature::new(kernel, measure, 1.0e-10);
19    let active = ActiveBayesianQuadrature::new(quadrature);
20
21    // Start from three evaluations; allow up to six more from a fixed candidate grid,
22    // stopping early once the posterior variance of the integral drops below 1e-6.
23    let initial_nodes = [-1.0, 0.0, 1.0];
24    let initial_values: Vec<f64> = initial_nodes.iter().copied().map(integrand).collect();
25    let candidates: Vec<f64> = (0..=23).map(|i| -2.875 + 0.25 * f64::from(i)).collect();
26
27    let initial = quadrature.posterior(&initial_nodes, &initial_values)?;
28    println!("initial posterior variance = {:.3e}", initial.variance());
29
30    let result = active.run(
31        &initial_nodes,
32        &initial_values,
33        &candidates,
34        6,
35        1.0e-6,
36        integrand,
37    )?;
38
39    for step in result.steps() {
40        println!(
41            "x = {:+.3}  predicted reduction = {:.3e}  posterior variance = {:.3e}",
42            step.point(),
43            step.predicted_variance_reduction(),
44            step.posterior_variance(),
45        );
46    }
47
48    let exact = (1.0_f64 / 3.0).sqrt() * (-0.25_f64 / 3.0).exp();
49    let posterior = result.posterior();
50    println!("stopped because: {:?}", result.termination());
51    println!(
52        "E[I | y] = {:.6} ± {:.3e}   (exact {exact:.6})",
53        posterior.mean(),
54        posterior.standard_deviation(),
55    );
56    Ok(())
57}

Trait Implementations§

Source§

impl Clone for ActiveDesignResult

Source§

fn clone(&self) -> ActiveDesignResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActiveDesignResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ActiveDesignResult

Source§

fn eq(&self, other: &ActiveDesignResult) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ActiveDesignResult

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.