nessai.posterior
================

.. py:module:: nessai.posterior

.. autoapi-nested-parse::

   Functions related to computing the posterior samples.

   ..
       !! processed by numpydoc !!


Functions
---------

.. autoapisummary::

   nessai.posterior.compute_weights
   nessai.posterior.draw_posterior_samples


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

.. py:function:: compute_weights(samples, nlive, expectation='logt')

   
   Returns the log-evidence and log-weights for the log-likelihood samples
   assumed to the result of nested sampling with nlive live points


   :Parameters:

       **samples** : array_like
           Log-likelihood samples.

       **nlive** : Union[int, array_like]
           Number of live points used in nested sampling.

       **expectation** : str, {logt, t}
           Method used to compute the expectation value for the shrinkage t.
           Choose between log <t> or <log t>. Defaults to <log t>.



   :Returns:

       float
           The computed log-evidence.

       array_like
           Array of computed weights (already normalised by the log-evidence).











   ..
       !! processed by numpydoc !!

.. py:function:: draw_posterior_samples(nested_samples, nlive=None, n=None, log_w=None, method='rejection_sampling', return_indices=False, expectation='logt', rng=None)

   
   Draw posterior samples given the nested samples.

   Requires either the posterior weights or the number of live points.

   :Parameters:

       **nested_samples** : structured array
           Array of nested samples.

       **nlive** : int, optional
           Number of live points used during nested sampling. Either this
           arguments or log_w must be specified.

       **n** : int, optional
           Number of samples to draw. Only used for importance sampling. If not
           specified, the effective sample size is used instead.

       **log_w** : array_like, optional
           Array of posterior weights. If specified the weights are not computed
           and these weights are used instead.

       **method** : str
           Method for drawing the posterior samples. Choose from
           
               - :code:`'rejection_sampling'`
               - :code:`'multinomial_resampling'`
               - :code:`'importance_sampling'` (same as multinomial)

       **return_indices** : bool
           If true return the indices of the accepted samples.

       **expectation** : str, {logt, t}
           Method used to compute the expectation value for the shrinkage t.
           Choose between log <t> or <log t>. Defaults to <log t>. Only used when
           :code:`log_w` is not specified.

       **rng** : numpy.random.Generator, optional
           Random number generator.



   :Returns:

       **posterior_samples** : numpy.ndarray
           Samples from the posterior distribution.

       **indices** : numpy.ndarray
           Indices of the accepted samples in the original nested samples.
           Only returned if :code:`return_indices` is True.




   :Raises:

       ValueError
           If the chosen method is not a valid method.







   ..
       !! processed by numpydoc !!

