Skip to contents

Sample from a posterior

Usage

# S3 method for class 'nsbi_posterior'
sample(x, size = 1000, n = size, obs = NULL, max_sampling_batches = 100L, seed = NULL, ...)

Arguments

x

An nsbi_posterior object (named x to satisfy the sample() generic).

size, n

Number of posterior draws (n is an alias for size).

obs

Observation to condition on (defaults to the posterior's x_obs).

max_sampling_batches

Safety cap on rejection-sampling rounds for bounded priors. The first round draws n rows; later rounds size the batch from the running acceptance rate (at most 100 * n rows), so low acceptance still fills n draws within a few rounds.

seed

Optional integer seed. The draws are reproducible for a given seed, and the caller's own random stream is restored afterwards.

...

Unused.

Value

An n x dim matrix of posterior draws (class nsbi_samples).