CONAN.funcs.credregionML
========================

.. py:function:: CONAN.funcs.credregionML(posterior=None, percentile=0.6827, pdf=None, xpdf=None)

   Compute a smoothed posterior density distribution and the minimum
   density for a given percentile of the highest posterior density.
   These outputs can be used to easily compute the HPD credible regions.

   :param posterior: A posterior distribution.
   :type posterior: 1D float ndarray
   :param percentile: The percentile (actually the fraction) of the credible region.
                      A value in the range: (0, 1).
   :type percentile: Float
   :param pdf: A smoothed-interpolated PDF of the posterior distribution.
   :type pdf: 1D float ndarray
   :param xpdf: The X location of the pdf values.
   :type xpdf: 1D float ndarray

   :returns: * **pdf** (*1D float ndarray*) -- A smoothed-interpolated PDF of the posterior distribution.
             * **xpdf** (*1D float ndarray*) -- The X location of the pdf values.
             * **HPDmin** (*Float*) -- The minimum density in the percentile-HPD region.

   .. rubric:: Example

   >>> import numpy as np
   >>> npoints = 100000
   >>> posterior = np.random.normal(0, 1.0, npoints)
   >>> pdf, xpdf, HPDmin = credregion(posterior)
   >>> # 68% HPD credible-region boundaries (somewhere close to +/-1.0):
   >>> print(np.amin(xpdf[pdf>HPDmin]), np.amax(xpdf[pdf>HPDmin]))
   >>> # Re-compute HPD for the 95% (withour recomputing the PDF):
   >>> pdf, xpdf, HPDmin = credregion(pdf=pdf, xpdf=xpdf, percentile=0.9545)
   >>> print(np.amin(xpdf[pdf>HPDmin]), np.amax(xpdf[pdf>HPDmin]))

