Statistics#

Set of elementary examples showing how the pyoed.stats subpackage can be employed.

Distributions#

Sampling#

Driver script to test Sampling various algorithms with simple PDFs.

Functions

main([run_mcmc, run_hmc, run_rejection])

Main driver.

banana_potential_energy_value(state[, a, b, rho])

Potential energy of the posterir.

banana_potential_energy_gradient(state[, a, ...])

Gradient of the Potential energy of the posterir.

banana_log_density(state[, a, b, rho])

The logarithm of the banana distribution PDF

banana_log_density_gradient(state[, a, b, rho])

The gradient of the logarithm of the banana distribution PDF

mcmc_sample_banana_distribution([...])

rejection_sample_banana_distribution([...])

get_base_output_dir()[source]#

Base output dir that enables modifying base output dir by changing pyoed settings class This is very helpful to globally steer output e.g., when running unittests.

banana_potential_energy_value(state, a=2.15, b=0.75, rho=0.9)[source]#

Potential energy of the posterir. This is dependent on the target state, not the momentum. It is the negative the posterior-log, and MUST be implemented for each distribution

banana_potential_energy_gradient(state, a=2.15, b=0.75, rho=0.9)[source]#

Gradient of the Potential energy of the posterir.

banana_log_density(state, a=2.15, b=0.75, rho=0.9)[source]#

The logarithm of the banana distribution PDF

banana_log_density_gradient(state, a=2.15, b=0.75, rho=0.9)[source]#

The gradient of the logarithm of the banana distribution PDF

mcmc_sample_banana_distribution(sample_size=1000, method='hmc')[source]#
rejection_sample_banana_distribution(sample_size=1000, proposal_mean=[0, 3], proposal_variance=2)[source]#
main(run_mcmc=True, run_hmc=True, run_rejection=True)[source]#

Main driver. Run all the sampler examples implemented in this module based on the passed flags

Parameters:
  • run_mcmc (bool) – if True, call/run the function mcmc_sample_banana_distribution

  • run_hmc (bool) – if True, call/run the function hmc_sample_banana_distribution

  • run_rejection (bool) – if True, call/run the function rejection_sample_banana_distribution