sequince.proposals
==================

.. py:module:: sequince.proposals


Attributes
----------

.. autoapisummary::

   sequince.proposals.logger


Classes
-------

.. autoapisummary::

   sequince.proposals.ProposalDistribution
   sequince.proposals.TrainableProposal
   sequince.proposals.FlowProposal


Functions
---------

.. autoapisummary::

   sequince.proposals.draw_initial_state
   sequince.proposals.draw_mcmc_initial_state


Module Contents
---------------

.. py:data:: logger

.. py:class:: ProposalDistribution

   Bases: :py:obj:`Protocol`


   Protocol for proposal distributions used by bridged SMC targets.


   .. py:method:: log_prob(particles, context = None)

      Evaluate the log proposal density in particle space.



   .. py:method:: sample(n_samples, context = None, *, rng = None, xp = None)

      Draw samples from the proposal distribution.



   .. py:method:: sample_and_log_prob(n_samples, context = None, *, rng = None, xp = None)

      Draw samples and return their log proposal densities.



.. py:class:: TrainableProposal

   Bases: :py:obj:`ProposalDistribution`, :py:obj:`Protocol`


   Proposal distribution that can be fitted to a particle population.


   .. py:method:: fit(particles, context = None, *, rng = None)

      Fit the proposal and return the fitted proposal.



.. py:class:: FlowProposal(flow, *, fit_kwargs = None)

   Bases: :py:obj:`TrainableProposal`


   Adapt a normalizing flow to the proposal-distribution interface.


   .. py:property:: flow
      :type: sequince.flows.NormalizingFlow



   .. py:method:: clone()


   .. py:method:: fit(particles, context = None, *, rng = None)

      Fit the proposal and return the fitted proposal.



   .. py:method:: state_dict()


   .. py:method:: load_state_dict(state)


   .. py:method:: log_prob(particles, context = None)

      Evaluate the log proposal density in particle space.



   .. py:method:: sample(n_samples, context = None, *, rng = None, xp = None)

      Draw samples from the proposal distribution.



   .. py:method:: sample_and_log_prob(n_samples, context = None, *, rng = None, xp = None)

      Draw samples and return their log proposal densities.



.. py:function:: draw_initial_state(proposal, n_particles, *, posterior = None, context = None, rng = None, xp = None)

   Draw one initial population and retain its target evaluation.

   The proposal must return finite particles. Its log density is only
   evaluated when the posterior has an explicit proposal endpoint; otherwise
   the proposal is assumed to be the prior. Non-finite posterior densities are
   retained because discarding them would condition the proposal and
   invalidate evidence estimates. NaN target evaluations are rejected as
   evaluation errors.


.. py:function:: draw_mcmc_initial_state(proposal, n_particles, log_prob_fn, *, context = None, max_batches = 100, rng = None, xp = None)

   Draw finite-target starting particles for standalone MCMC.

   Unlike :func:`draw_initial_state`, this function conditions the proposal by
   rejecting particles whose target log density is ``-inf``. It must not be
   used to initialize an evidence estimator.


