NUTSChain

Struct NUTSChain 

Source
pub struct NUTSChain<T, B, GTarget>
where B: AutodiffBackend,
{ pub position: Tensor<B, 1>, /* private fields */ }
Expand description

Single-chain state and adaptation for NUTS.

Manages the dynamic trajectory building, dual-averaging adaptation of step size, and current position for one chain.

Fields§

§position: Tensor<B, 1>

Current position in parameter space.

Implementations§

Source§

impl<T, B, GTarget> NUTSChain<T, B, GTarget>

Source

pub fn new( target: GTarget, initial_position: Vec<T>, target_accept_p: T, ) -> Self

Constructs a new NUTSChain for a single chain with the given initial position.

§Parameters
  • target: The target distribution implementing GradientTarget.
  • initial_position: Initial position vector of length D.
  • target_accept_p: Desired average acceptance probability for adaptation.
§Returns

An initialized NUTSChain.

Source

pub fn set_seed(self, seed: u64) -> Self

Sets a new random seed for this chain to ensure reproducibility.

§Parameters
  • seed: Seed value for the chain’s RNG.
§Returns

self with the RNG re-seeded.

Source

pub fn run(&mut self, n_collect: usize, n_discard: usize) -> Tensor<B, 2>

Runs the chain for n_collect + n_discard steps, adapting during burn-in and returning collected samples.

§Parameters
  • n_collect: Number of samples to collect after adaptation.
  • n_discard: Number of burn-in steps for adaptation.
§Returns

A 2D tensor of shape [n_collect, D] containing collected samples.

Source

pub fn step(&mut self)

Performs one NUTS update step, including tree expansion and adaptation updates.

This method updates self.position and adaptation statistics in-place.

Trait Implementations§

Source§

impl<T: Clone, B, GTarget: Clone> Clone for NUTSChain<T, B, GTarget>

Source§

fn clone(&self) -> NUTSChain<T, B, GTarget>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, B, GTarget: Debug> Debug for NUTSChain<T, B, GTarget>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, B, GTarget> Freeze for NUTSChain<T, B, GTarget>

§

impl<T, B, GTarget> RefUnwindSafe for NUTSChain<T, B, GTarget>

§

impl<T, B, GTarget> Send for NUTSChain<T, B, GTarget>
where GTarget: Send, T: Send,

§

impl<T, B, GTarget> Sync for NUTSChain<T, B, GTarget>
where GTarget: Sync, T: Sync,

§

impl<T, B, GTarget> Unpin for NUTSChain<T, B, GTarget>

§

impl<T, B, GTarget> UnwindSafe for NUTSChain<T, B, GTarget>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V