jexplore.steps ============== .. py:module:: jexplore.steps .. autoapi-nested-parse:: Markov steps Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/jexplore/steps/colored/index /autoapi/jexplore/steps/colored_alt/index /autoapi/jexplore/steps/de/index /autoapi/jexplore/steps/direct/index /autoapi/jexplore/steps/mh/index /autoapi/jexplore/steps/modsel/index /autoapi/jexplore/steps/rwalk/index /autoapi/jexplore/steps/single_masked/index /autoapi/jexplore/steps/step/index /autoapi/jexplore/steps/stretch/index /autoapi/jexplore/steps/tswap/index Classes ------- .. autoapisummary:: jexplore.steps.DEStep jexplore.steps.Gaussian jexplore.steps.Uniform jexplore.steps.GaussianRandomWalk jexplore.steps.StudentTRandomWalk jexplore.steps.Stretch jexplore.steps.TSwap Package Contents ---------------- .. py:class:: DEStep[Tepoch: jexplore.sampling.EpochMH, Tstate: jexplore.sampling.StateMH, Tsampling: jexplore.sampling.SamplingMH](gamma = 2.38, ngroups = 2, permute = False) Bases: :py:obj:`jexplore.steps.colored.ColoredSC`\ [\ :py:obj:`Tepoch`\ , :py:obj:`Tstate`\ , :py:obj:`Tsampling`\ ] Class implementing a Differential evolution step :param gamma: :math:`\gamma` scale parameter :param ngroups: number of groups. Default 2. :param permute: if true walkers are permuted at each iteration. .. py:attribute:: gamma :type: float DE proposal :math:`\gamma` parameter .. py:attribute:: sigma :type: jax.Array gamma distribution :math:`\sigma = \frac{\gamma}{2\sqrt{D}}` .. py:attribute:: npart :type: int :value: 2 number of partners needed to build the proposal .. py:method:: build(epoch) Step initialisation method. It extends :py:attr:`jexplore.steps.colored.Colored.build` by simply adding the computation of the :math:`\sigma` of the :math:`\gamma` distribution. :param epoch: current epoch. .. py:method:: sample_gamma(key, state) Sample :math:`\gamma` from normal distribution :param key: PRNG key :param size: output size :return: samples .. py:method:: proposal(key, state, group, cgroup) Propose a new state according to the DE proposal algorithm. :param key: PRNG key :param state: current state :return: new state and the boolean mask of the chains modified by the step. .. py:class:: Gaussian(mask = None) Bases: :py:obj:`Direct` Sampling from a Gaussian distribution (to be completed). :param mask: proposal dimensions mask (default all space) .. py:class:: Uniform(mask = None, minval = 0.0, maxval = 1.0) Bases: :py:obj:`Direct` Sampling from a uniform distribution in a box. :param mask: proposal dimensions mask (default all space) :param minval: minimum (inclusive) value broadcast-compatible with shape for the range (default 0). :param maxval: maximum (exclusive) value broadcast-compatible with shape for the range (default 1). .. py:class:: GaussianRandomWalk(mask = None) Bases: :py:obj:`MVRandomWalk` Gaussian random walk proposal. :param mask: proposal dimensions mask (default all space) .. py:class:: StudentTRandomWalk(mask = None, nu=5.0) Bases: :py:obj:`MVRandomWalk` Student-T random walk proposal. :param mask: proposal dimensions mask (default all space) :param float nu: Student-T nu parameter (default: 5) .. py:class:: Stretch[Tepoch: jexplore.sampling.EpochMH, Tstate: jexplore.sampling.StateMH, Tsampling: jexplore.sampling.SamplingMH](a = 2.0, ngroups = 2, permute = False) Bases: :py:obj:`jexplore.steps.colored.ColoredSC`\ [\ :py:obj:`Tepoch`\ , :py:obj:`Tstate`\ , :py:obj:`Tsampling`\ ] Class implementing a MH steps based on stretch proposal :param a: stretch proposal `a` parameter :param ngroups: number of groups. Default 2. :param permute: if true walkers are permuted at each iteration. .. py:attribute:: npart :type: int :value: 1 number of partners needed to build the proposal .. py:attribute:: a :type: float stretch proposal `a` parameter .. py:attribute:: sa .. py:method:: sample_z(key, size) Sample the z distribution :param key: PRNG key :param size: output size :return: samples .. py:method:: proposal(key, state, group, cgroup) Propose a new state according to the stretch proposal algorithm. :param key: PRNG key :param state: current state :param group: indexes of the color chains :param cgroup: indexes of the complementary chains for this color. :return: new state and the boolean mask of the chains modified by the step. .. py:class:: TSwap[Tepoch: jexplore.sampling.mh.EpochMH, Tstate: jexplore.sampling.mh.StateMH, Tsampling: jexplore.sampling.mh.SamplingMH](ngroups = -1, permute = False, duplicate = False, adjust = False) Bases: :py:obj:`jexplore.steps.colored.ColoredMH`\ [\ :py:obj:`Tepoch`\ , :py:obj:`Tstate`\ , :py:obj:`Tsampling`\ ] Class for MH temperature swap step :param ngroups: number of groups. If -1 (default) the temperature swapping is fully serial. :param permute: when true permute values before each iteration :param duplicate: duplicate chains in group to make colors groups even :param adjust: adjust the number of group to have even colors groups .. py:method:: grouping() Defines colors chain groups by grouping temperatures. The :math:`i` th color group contains chains for all walkers and with temperature indices :math:`t \mod G = i + 1` and for each of these chains the complementary group of chains contains the chain with temperature :math:`t - 1`. :return: indexes of the chains of each color, indexes of the complementary chains for each color. .. py:method:: colored_step(key, state, group, cgroup) Temperature swap step for a single color. Propose a swap of two consecutive temperatures and accept/reject it according to MH condition. :param key: PRNG key :param state: current state :param group: indexes of the color chains :param cgroup: indexes of the complementary chains for this color. :return: new state and boolean mask of the changed chains