bebi103.hmc.convert_samples

bebi103.hmc.convert_samples(samples, out_format, inc_warmup=False, arviz_kwargs=None)

Converts samples to a new format.

Parameters:
  • samples (dict, cmdstanpy.CmdStanMCMC, xarray.DataTree, pandas.DataFrame, or polars.DataFrame) – Results from an MCMC sampling to convert to desired format.

  • out_format (str, one of 'dict', 'arviz', 'pandas', 'polars') –

    The desired output format of the samples. - dict: Dictionary of expectands and HMC diagnostics. Each item

    is a 2D Numpy array. The first dimension indexes the Markov chains and the second indexes the sequential states within each chain.

    • arviz: An xarray.DataTree instance as used by ArviZ. Only valid if samples is a cmdstanpy.CmdStanMCMC instance.

    • pandas.DataFrame: Each row of the data frame is a chain/draw with expectand values and HMC diagnostic results.

    • polars.DataFrame: Each row of the data frame is a chain/draw with expectand values and HMC diagnostic results.

  • inc_warmup (bool, default False) – If True, include warmup samples. Only active if samples is a cmdstanpy.CmdStanMCMC instance.

  • arviz_kwargs (dict, default None) – Keyword arguments to be passed to arviz_base.from_cmdstanpy().

Returns:

output – An single instance of the desired out_format is returned.

Return type:

various formats