mcmc_sample

mcmc_sample(
    data,
    distribution='Normal',
    sampler='RWMH',
    iterations=None,
    warmup=None,
    chains=None,
    thinning=None,
    output_length=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
output_length int Total number of retained draws across all chains (sampler default, 10,000, if omitted). The ported sampler collects ceil(output_length / chains) draws per chain after the iteration loop. The ported floor is 100 and it is refused below that. 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).