:py:mod:`nessai.utils.rescaling` ================================ .. py:module:: nessai.utils.rescaling .. autoapi-nested-parse:: Utilities related to rescaling. .. !! processed by numpydoc !! Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: nessai.utils.rescaling.rescale_zero_to_one nessai.utils.rescaling.inverse_rescale_zero_to_one nessai.utils.rescaling.rescale_minus_one_to_one nessai.utils.rescaling.inverse_rescale_minus_one_to_one nessai.utils.rescaling.detect_edge nessai.utils.rescaling.configure_edge_detection nessai.utils.rescaling.determine_rescaled_bounds nessai.utils.rescaling.logit nessai.utils.rescaling.sigmoid Attributes ~~~~~~~~~~ .. autoapisummary:: nessai.utils.rescaling.logger nessai.utils.rescaling.rescaling_functions .. py:data:: logger .. !! processed by numpydoc !! .. py:function:: rescale_zero_to_one(x, xmin, xmax) Rescale a value to 0 to 1 :Parameters: **x** : ndarray Array of values to rescale **xmin, xmax** : floats Minimum and maximum values to use for rescaling :Returns: ndarray Array of rescaled values ndarray Array of log determinants of Jacobians for each sample .. !! processed by numpydoc !! .. py:function:: inverse_rescale_zero_to_one(x, xmin, xmax) Rescale from 0 to 1 to xmin to xmax :Parameters: **x** : ndarray Array of values to rescale **xmin, xmax** : floats Minimum and maximum values to use for rescaling :Returns: ndarray Array of rescaled values ndarray Array of log determinants of Jacobians for each sample .. !! processed by numpydoc !! .. py:function:: rescale_minus_one_to_one(x, xmin, xmax) Rescale a value to -1 to 1 :Parameters: **x** : ndarray Array of values to rescale **xmin, xmax** : floats Minimum and maximum values to use for rescaling :Returns: ndarray Array of rescaled values ndarray Array of log determinants of Jacobians for each sample .. !! processed by numpydoc !! .. py:function:: inverse_rescale_minus_one_to_one(x, xmin, xmax) Rescale from -1 to 1 to xmin to xmax :Parameters: **x** : ndarray Array of values to rescale **xmin, xmax** : floats Minimum and maximum values to use for rescaling :Returns: ndarray Array of rescaled values ndarray Array of log determinants of Jacobians for each sample .. !! processed by numpydoc !! .. py:function:: detect_edge(x, x_range=None, percent=0.1, cutoff=0.5, nbins='auto', allow_both=False, allow_none=False, allowed_bounds=['lower', 'upper'], test=None) Detect edges in input distributions based on the density. :Parameters: **x: array_like** Samples **x_range** : array_like, optional Lower and upper bounds used to check inversion, if not specified min and max of data are used. **percent: float (0.1)** Percentage of interval used to check edges **cutoff: float (0.1)** Minimum fraction of the maximum density contained within the percentage of the interval specified **nbins** : float or 'auto' Number of bins used for histogram. **allow_both: bool** Allow function to return both instead of force either upper or lower **allow_none: bool** Allow for neither lower or upper bound to be returned **allowed_bounds** : list List of alloweds bounds. **test** : str or None If not None this skips the process and just returns the value of test. This is used to verify the inversion in all possible scenarios. :Returns: str or False, {'lower', 'upper', 'both', False} Returns the boundary to apply the inversion or False is no inversion is to be applied .. !! processed by numpydoc !! .. py:function:: configure_edge_detection(d, detect_edges) Configure parameters for edge detection :Parameters: **d** : dict Dictionary of kwargs passed to detect_edge. **detect_edges** : bool If true allows for no inversion to be applied. :Returns: dict Updated kwargs .. !! processed by numpydoc !! .. py:function:: determine_rescaled_bounds(prior_min, prior_max, x_min, x_max, invert=None, inversion=False, offset=0, rescale_bounds=[-1, 1]) Determine the values of the prior min and max in the rescaled space. :Parameters: **prior_min** : float Minimum of the prior. **prior_max** : float Maximum of the prior. **x_min** : float New minimum. **x_max** : float New maximum. **invert** : False or {'upper', 'lower', 'both'}, optional Type of inversion. `inversion` must also be set to True. **inversion** : bool, optional Indicate if the rescaling bounds have been set for inversion. If True and invert is None or False, then the rescale bounds are assumed to be [-1, 1] rather than [0, 1] (the default for inverted parameters.) **offset** : float, optional Offset to subtract from the values prior to rescaling. **rescaled_bounds** : list or tuple Lower and upper bound which x has been rescaled to. In inversion=True, these values are ignored to match behaviour in the :py:class:`~nessai.reparameterisations.RescaleToBounds`. .. !! processed by numpydoc !! .. py:function:: logit(x, fuzz=1e-12) Logit function that also returns log Jacobian determinant. See :py:func:`nessai.utils.rescaling.sigmoid` for the inverse. :Parameters: **x** : float or ndarray Array of values **fuzz** : float, optional Fuzz used to avoid nans in logit. Values are rescaled from [0, 1] to [0-fuzz, 1+fuzz]. :Returns: float or ndarray Rescaled values. float or ndarray Log Jacobian determinant. .. !! processed by numpydoc !! .. py:function:: sigmoid(x, fuzz=1e-12) Sigmoid function that also returns log Jacobian determinant. See :py:func:`nessai.utils.rescaling.logit` for the inverse. :Parameters: **x** : float or ndarray Array of values **fuzz** : float, optional Fuzz used to avoid nans in logit :Returns: float or ndarray Rescaled values. float or ndarray Log Jacobian determinant. .. !! processed by numpydoc !! .. py:data:: rescaling_functions .. !! processed by numpydoc !!