fstats_mcmc Module



Interfaces

interface

  • public subroutine evaluate_model(this, xdata, xc, y)

    Evaluates the model at the supplied values.

    Arguments

    Type IntentOptional Attributes Name
    class(mcmc_target), intent(in) :: this

    The mcmc_target object.

    real(kind=real64), intent(in), dimension(:) :: xdata

    An M-element array containing the values at which to evaluate the model.

    real(kind=real64), intent(in), dimension(:) :: xc

    An N-element array containing the model parameters.

    real(kind=real64), intent(out), dimension(:) :: y

    An M-element array where the resulting model values wil be written.


Derived Types

type, public ::  chain_builder

A type allowing for the construction of chain of values.

Type-Bound Procedures

procedure, public :: get_chain => cb_get_chain
procedure, public :: get_chain_length => cb_get_chain_length
procedure, public :: get_state_variable_count => cb_get_nvars
procedure, public :: push_new_state => cb_push
procedure, public :: reset => cb_clear_chain

type, public ::  mcmc_proposal

Defines a type responsible for generating a proposal state for a Monte-Carlo, Markov-Chain sampler.

Type-Bound Procedures

procedure, public :: generate_sample => mp_gen
procedure, public :: get_param_scale => mp_get_param_scale
procedure, public :: get_recenter => mp_get_recenter
procedure, public :: get_scale => mp_get_scale
procedure, public :: set_param_scale => mp_set_param_scale
procedure, public :: set_param_scales => mp_set_param_scales
procedure, public :: set_recenter => mp_set_recenter
procedure, public :: set_scale => mp_set_scale

type, public, extends(chain_builder) ::  mcmc_sampler

An implementation of the Metropolis-Hastings algorithm for the generation of a Markov chain.

Type-Bound Procedures

procedure, public :: get_accepted_count => ms_get_num_accepted
procedure, public :: get_chain => cb_get_chain
procedure, public :: get_chain_length => cb_get_chain_length
procedure, public :: get_state_variable_count => cb_get_nvars
procedure, public :: on_acceptance => ms_on_success
procedure, public :: on_rejection => ms_on_rejection
procedure, public :: push_new_state => cb_push
procedure, public :: reset => cb_clear_chain
procedure, public :: sample => ms_sample

type, public ::  mcmc_target

Defines a model of the target distribution(s).

Components

Type Visibility Attributes Name Initial
real(kind=real64), public :: data_noise = 1.0d0

A parameter representing the noise in the data.

integer(kind=int32), public :: likelihood_parallel_threshold = 10000

Minimum observation count for a threaded likelihood reduction. Adjust for the workload; nested worker teams are not created.

Type-Bound Procedures

procedure, public :: add_parameter => mt_add_param
procedure, public :: evaluate_log_variance_prior => mt_eval_log_var_prior ..\..\

Prior density in log-variance coordinates, including the Jacobian.<\p>

procedure, public :: evaluate_prior => mt_eval_prior
procedure, public :: evaluate_variance_prior => mt_eval_var_prior
procedure, public :: get_parameter => mt_get_param
procedure, public :: get_parameter_count => mt_get_param_count
procedure, public :: likelihood => mt_likelihood
procedure, public :: likelihood_log_variance => mt_log_likelihood ..\..\

Gaussian log likelihood accepting log variance directly.<\p>

procedure, public :: log_posterior => mt_log_posterior ..\..\

Posterior density in parameter\log-variance coordinates.<\p>

procedure(evaluate_model), public, deferred :: model
procedure, public :: sample_variance_prior => mt_sample_var_prior

Subroutines

public subroutine sample_chains(samplers, xdata, ydata, proposals, targets, niter)

Samples independent chains concurrently using OpenMP. Initialize each target independently, with no shared mutable state in distributions, models, proposals, or sampler callbacks. The compiler runtime must provide thread-safe RANDOM_NUMBER (as GNU Fortran does). Random streams and reproducibility depend on the compiler runtime and thread scheduling; no per-chain seed guarantee is provided.

Arguments

Type IntentOptional Attributes Name
class(mcmc_sampler), intent(inout) :: samplers(:)

One sampler per chain; existing samples are retained as in sample.

real(kind=real64), intent(in) :: xdata(:)

Shared, read-only observations.

real(kind=real64), intent(in) :: ydata(:)

Shared, read-only observations.

class(mcmc_proposal), intent(inout) :: proposals(:)

One independently configured proposal per chain.

class(mcmc_target), intent(inout) :: targets(:)

One independently initialized target per chain.

integer(kind=int32), intent(in), optional :: niter

Iterations per chain; defaults to 10,000.