pymc.sampling.jax.sample_numpyro_nuts#
- pymc.sampling.jax.sample_numpyro_nuts(draws=1000, tune=1000, chains=4, target_accept=0.8, random_seed=None, initvals=None, model=None, var_names=None, progressbar=True, keep_untransformed=False, chain_method='parallel', postprocessing_backend=None, postprocessing_chunks=None, idata_kwargs=None, nuts_kwargs=None)[source]#
Draw samples from the posterior using the NUTS method from the
numpyrolibrary.- Parameters
- draws
int, default 1000 The number of samples to draw. The number of tuned samples are discarded by default.
- tune
int, default 1000 Number of iterations to tune. Samplers adjust the step sizes, scalings or similar during tuning. Tuning samples will be drawn in addition to the number specified in the
drawsargument.- chains
int, default 4 The number of chains to sample.
- target_accept
floatin[0, 1]. The step size is tuned such that we approximate this acceptance rate. Higher values like 0.9 or 0.95 often work better for problematic posteriors.
- random_seed
int,RandomStateorGenerator, optional Random seed used by the sampling steps.
- initvals: StartDict or Sequence[Optional[StartDict]], optional
Initial values for random variables provided as a dictionary (or sequence of dictionaries) mapping the random variable (by name or reference) to desired starting values.
- model
Model, optional Model to sample from. The model needs to have free random variables. When inside a
withmodel context, it defaults to that model, otherwise the model must be passed explicitly.- var_namessequence of
str, optional Names of variables for which to compute the posterior samples. Defaults to all variables in the posterior.
- progressbarbool, default
True Whether or not to display a progress bar in the command line. The bar shows the percentage of completion, the sampling speed in samples per second (SPS), and the estimated remaining time until completion (“expected time of arrival”; ETA).
- keep_untransformedbool, default
False Include untransformed variables in the posterior samples. Defaults to False.
- chain_method
str, default “parallel” Specify how samples should be drawn. The choices include “sequential”, “parallel”, and “vectorized”.
- postprocessing_backend
Optional[str] Specify how postprocessing should be computed. gpu or cpu
- postprocessing_chunks: Optional[int], default None
Specify the number of chunks the postprocessing should be computed in. More chunks reduces memory usage at the cost of losing some vectorization, None uses jax.vmap
- idata_kwargs
dict, optional Keyword arguments for
arviz.from_dict(). It also accepts a boolean as value for thelog_likelihoodkey to indicate that the pointwise log likelihood should not be included in the returned object. Values forobserved_data,constant_data,coords, anddimsare inferred from themodelargument if not provided inidata_kwargs. Ifcoordsanddimsare provided, they are used to update the inferred dictionaries.- nuts_kwargs: dict, optional
Keyword arguments for
numpyro.infer.NUTS().
- draws
- Returns
InferenceDataArviZ
InferenceDataobject that contains the posterior samples, together with their respective sample stats and pointwise log likeihood values (unless skipped withidata_kwargs).