mcmc_sample

mcmc_sample(
    data,
    distribution='Normal',
    sampler='RWMH',
    iterations=None,
    warmup=None,
    chains=None,
    thinning=None,
    seed=12345,
    initialize='MAP',
)

Sample the posterior of a distribution’s parameters by MCMC.

Fits distribution to data with uniform priors spanning the family’s parameter constraints (exactly the C# GetParameterConstraints bounds) and returns the full sampler output: per-chain draws, acceptance rates, the MAP estimate, posterior summaries, and Gelman-Rubin / effective sample size diagnostics.

Runs the ported serial chain driver with the C# default seed, so a seeded run reproduces the C# sampler stream bit-for-bit (and matches corehydror exactly).

Parameters

Name Type Description Default
data array-like of float Observations. required
distribution str Distribution family name; see :func:corehydropy.distribution_names. 'Normal'
sampler ('RWMH', 'ARWMH', 'DEMCz', 'DEMCzs', 'HMC', 'NUTS', 'SNIS') The MCMC sampler. "RWMH"
iterations int Iterations per chain (sampler default if omitted). None
warmup int Warm-up iterations discarded from each chain (sampler default if omitted). None
chains int Number of chains (sampler default if omitted). None
thinning int Thinning interval (sampler default if omitted). None
seed int PRNG seed; 12345 is the C# default. 12345
initialize ('MAP', 'Randomize') Chain initialization: from the MAP estimate (the C# default) or randomized draws from the priors. "MAP"

Returns

Name Type Description
dict Keys parameters (parameter names), chains (list of (n_draws, n_params) arrays, one per chain), acceptance_rates, map (parameter values at the posterior mode), map_fitness, posterior_mean, posterior_sd, posterior_median, posterior_lower_ci, posterior_upper_ci, rhat, and ess (all per-parameter arrays).