nessai.reparameterisations.rescale
==================================

.. py:module:: nessai.reparameterisations.rescale

.. autoapi-nested-parse::

   Reparameterisations that rescale the parameters.

   ..
       !! processed by numpydoc !!


Classes
-------

.. autoapisummary::

   nessai.reparameterisations.rescale.PrePostRescalingMixin
   nessai.reparameterisations.rescale.ScaleAndShift
   nessai.reparameterisations.rescale.Rescale
   nessai.reparameterisations.rescale.RescaleToBounds


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

.. py:class:: PrePostRescalingMixin

   
   Mixin that adds support for pre- and post-rescaling functions
















   ..
       !! processed by numpydoc !!

   .. py:method:: configure_pre_rescaling(pre_rescaling)

      
      Configure the rescaling applied before the standard rescaling.


      :Parameters:

          **pre_rescaling** : str or Tuple[Callable, Callable]
              Name of the pre-rescaling of tuple contain the forward and inverse
              functions that should return the rescaled value and the Jacobian.














      ..
          !! processed by numpydoc !!


   .. py:method:: configure_post_rescaling(post_rescaling)

      
      Configure the rescaling applied after the standard rescaling.

      Used to apply the logit/sigmoid transforms after rescaling to [0, 1]

      :Parameters:

          **post_rescaling** : str or Tuple[Callable, Callable]
              Name of the post-rescaling of tuple contain the forward and inverse
              functions that should return the rescaled value and the Jacobian.














      ..
          !! processed by numpydoc !!


   .. py:method:: pre_rescaling(x)

      
      Function applied before rescaling to bounds
















      ..
          !! processed by numpydoc !!


   .. py:method:: pre_rescaling_inv(x)

      
      Inverse of function applied before rescaling to bounds
















      ..
          !! processed by numpydoc !!


   .. py:method:: post_rescaling(x)

      
      Function applied after rescaling to bounds
















      ..
          !! processed by numpydoc !!


   .. py:method:: post_rescaling_inv(x)

      
      Inverse of function applied after rescaling to bounds
















      ..
          !! processed by numpydoc !!


.. py:class:: ScaleAndShift(parameters=None, prior_bounds=None, scale=None, shift=None, estimate_scale=False, estimate_shift=False, pre_rescaling=None, post_rescaling=None, rng=None)

   Bases: :py:obj:`PrePostRescalingMixin`, :py:obj:`nessai.reparameterisations.base.Reparameterisation`


   
   Reparameterisation that shifts and scales by a value.

   Applies

   .. math::
       x' = (x - shift) / scale

   Can apply the Z-score rescaling if :code:`estimate_scale` and
   :code:`estimate_shift` are both enabled. The values are initialised to
   one and zero respectively.

   :Parameters:

       **parameters** : Union[str, List[str]]
           Name of parameters to reparameterise.

       **prior_bounds** : list, dict or None
           Prior bounds for the parameter(s).

       **scale** : Optional[float]
           Scaling constant. If not specified, :code:`estimate_scale` must be
           True.

       **shift** : Optional[float]
           Shift constant. If not specified, no shift is applied.

       **estimate_scale** : bool
           If true, the value of :code:`scale` will be ignored and the standard
           deviation of the data will be used.

       **estimate_shift** : bool
           If true, the value of :code:`shift` will be ignored and the standard
           deviation of the data will be used.

       **pre_rescaling** : tuple of functions or str
           A function that applies a rescaling prior to the main rescaling and
           its inverse. Each function should return a value and the log-Jacobian
           determinant. Alternatively, can be the name of a known rescaling.

       **post_rescaling** : tuple of functions or str
           A function that applies a rescaling after to the main rescaling and
           its inverse. Each function should return a value and the log-Jacobian
           determinant. Alternatively, can be the name of a known rescaling














   ..
       !! processed by numpydoc !!

   .. py:method:: reparameterise(x, x_prime, log_j, **kwargs)

      
      Apply the reparameterisation to convert from x-space
      to x'-space


      :Parameters:

          **x** : structured array
              Array

          **x_prime** : structured array
              Array to be update

          **log_j** : Log jacobian to be updated
              ..














      ..
          !! processed by numpydoc !!


   .. py:method:: inverse_reparameterise(x, x_prime, log_j, **kwargs)

      
      Apply the reparameterisation to convert from x-space
      to x'-space


      :Parameters:

          **x** : structured array
              Array

          **x_prime** : structured array
              Array to be update

          **log_j** : Log jacobian to be updated
              ..














      ..
          !! processed by numpydoc !!


   .. py:method:: update(x)

      
      Update the scale and shift parameters if enabled.
















      ..
          !! processed by numpydoc !!


   .. py:method:: reset()

      
      Reset the scale and shift parameters
















      ..
          !! processed by numpydoc !!


.. py:class:: Rescale(parameters=None, prior_bounds=None, scale=None, shift=None, estimate_scale=False, estimate_shift=False, pre_rescaling=None, post_rescaling=None, rng=None)

   Bases: :py:obj:`ScaleAndShift`


   
   Reparameterisation that rescales the parameters by a constant factor
   that does not depend on the prior bounds.
















   ..
       !! processed by numpydoc !!

.. py:class:: RescaleToBounds(parameters=None, prior_bounds=None, prior=None, rescale_bounds=None, boundary_inversion=None, detect_edges=False, inversion_type='split', detect_edges_kwargs=None, offset=False, update_bounds=True, pre_rescaling=None, post_rescaling=None, rng=None)

   Bases: :py:obj:`PrePostRescalingMixin`, :py:obj:`nessai.reparameterisations.base.Reparameterisation`


   
   Reparameterisation that maps to the specified interval.

   By default the interval is [-1, 1]. Also includes options for
   boundary inversion.

   This reparameterisation can handle multiple parameters.

   :Parameters:

       **parameters** : list of str
           List of the names of parameters

       **prior_bounds** : dict
           Dictionary of prior bounds for each parameter. Does not need to be
           specified by the user.

       **rescale_bounds** : list of tuples, optional
           Bounds to rescale to.

       **update_bounds** : bool, optional
           Enable or disable updating bounds.

       **prior** : {'uniform', None}
           Type of prior used, if uniform prime prior is enabled.

       **boundary_inversion** : bool, list, dict, optional
           Configuration for boundary inversion. If a list, inversion is only
           applied to the parameters in the list based on `inversion_type`. If
           a `dict` then each item should be a parameter and a corresponding
           inversion type `{'split', 'inversion'}`.

       **detect_edges** : bool, optional
           Enable or disable edge detection for inversion.

       **detect_edges_kwargs** : dict, optional
           Dictionary of kwargs used to configure edge detection.

       **offset** : bool, optional
           Enable or disable offset subtraction. If `True` then the mean value
           of the prior is subtract of the parameter before the rescaling is
           applied. This is computed and applied after the 'pre-rescaling' if it
           has been specified.

       **pre_rescaling** : tuple of functions
           A function that applies a rescaling prior to the main rescaling and
           its inverse. Each function should return a value and the log-Jacobian
           determinant.

       **post_rescaling** : tuple of functions or {'logit}
           A function that applies a rescaling after to the main rescaling and
           its inverse. Each function should return a value and the log-Jacobian
           determinant. For example applying a logit after rescaling to [0, 1].














   ..
       !! processed by numpydoc !!

   .. py:method:: configure_post_rescaling(post_rescaling)

      
      Configure the rescaling applied after the standard rescaling.

      Used to apply the logit/sigmoid transforms after rescaling to [0, 1]

      :Parameters:

          **post_rescaling** : str or Tuple[Callable, Callable]
              Name of the post-rescaling of tuple contain the forward and inverse
              functions that should return the rescaled value and the Jacobian.














      ..
          !! processed by numpydoc !!


   .. py:method:: pre_rescaling(x)

      
      Function applied before rescaling to bounds
















      ..
          !! processed by numpydoc !!


   .. py:method:: pre_rescaling_inv(x)

      
      Inverse of function applied before rescaling to bounds
















      ..
          !! processed by numpydoc !!


   .. py:method:: post_rescaling(x)

      
      Function applied after rescaling to bounds
















      ..
          !! processed by numpydoc !!


   .. py:method:: post_rescaling_inv(x)

      
      Inverse of function applied after rescaling to bounds
















      ..
          !! processed by numpydoc !!


   .. py:method:: reparameterise(x, x_prime, log_j, compute_radius=False, **kwargs)

      
      Rescale inputs to the prime space


      :Parameters:

          **x, x_prime** :  array_like
              Arrays of samples in the physical and prime space

          **log_j** : array_like
              Array of values of log-Jacobian

          **compute_radius** : bool, optional
              If true force duplicate for inversion

          **kwargs**
              Parsed to inversion function














      ..
          !! processed by numpydoc !!


   .. py:method:: inverse_reparameterise(x, x_prime, log_j, **kwargs)

      
      Map inputs to the physical space from the prime space
















      ..
          !! processed by numpydoc !!


   .. py:method:: reset_inversion()

      
      Reset the edges for inversion
















      ..
          !! processed by numpydoc !!


   .. py:method:: set_bounds(prior_bounds)

      
      Set the initial bounds for rescaling
















      ..
          !! processed by numpydoc !!


   .. py:method:: update_bounds(x)

      
      Update the bounds used for the reparameterisation
















      ..
          !! processed by numpydoc !!


   .. py:method:: update(x)

      
      Update the reparameterisation given some points.

      Includes resetting the inversions and updating the bounds.















      ..
          !! processed by numpydoc !!


   .. py:method:: reset()

      
      Reset the reparameterisation.

      Resets the inversion and the bounds.















      ..
          !! processed by numpydoc !!


