nessai.reparameterisations.rescale

Reparameterisations that rescale the parameters.

Module Contents

Classes

ScaleAndShift

Reparameterisation that shifts and scales by a value.

Rescale

Reparameterisation that rescales the parameters by a constant factor

RescaleToBounds

Reparameterisation that maps to the specified interval.

class nessai.reparameterisations.rescale.ScaleAndShift(parameters=None, prior_bounds=None, scale=None, shift=None, estimate_scale=False, estimate_shift=False)

Bases: nessai.reparameterisations.base.Reparameterisation

Reparameterisation that shifts and scales by a value.

Applies

\[x' = (x - shift) / scale\]

Can apply the Z-score rescaling if estimate_scale and estimate_shift are both enabled.

Parameters:
parametersUnion[str, List[str]]

Name of parameters to reparameterise.

prior_boundslist, dict or None

Prior bounds for the parameter(s).

scaleOptional[float]

Scaling constant. If not specified, estimate_scale must be True.

shiftOptional[float]

Shift constant. If not specified, no shift is applied.

estimate_scalebool

If true, the value of scale will be ignored and the standard deviation of the data will be used.

estimate_shiftbool

If true, the value of shift will be ignored and the standard deviation of the data will be used.

reparameterise(x, x_prime, log_j, **kwargs)

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

Parameters:
xstructured array

Array

x_primestructured array

Array to be update

log_jLog jacobian to be updated
inverse_reparameterise(x, x_prime, log_j, **kwargs)

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

Parameters:
xstructured array

Array

x_primestructured array

Array to be update

log_jLog jacobian to be updated
update(x)

Update the scale and shift parameters if enabled.

class nessai.reparameterisations.rescale.Rescale(parameters=None, prior_bounds=None, scale=None, shift=None, estimate_scale=False, estimate_shift=False)

Bases: ScaleAndShift

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

class nessai.reparameterisations.rescale.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)

Bases: 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:
parameterslist of str

List of the names of parameters

prior_boundsdict

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

rescale_boundslist of tuples, optional

Bounds to rescale to.

update_boundsbool, optional

Enable or disable updating bounds.

prior{‘uniform’, None}

Type of prior used, if uniform prime prior is enabled.

boundary_inversionbool, 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_edgesbool, optional

Enable or disable edge detection for inversion.

detect_edges_kwargsdict, optional

Dictionary of kwargs used to configure edge detection.

offsetbool, 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_rescalingtuple 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_rescalingtuple 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].

configure_pre_rescaling(pre_rescaling)

Configure the rescaling applied before the standard rescaling.

Used in DistanceReparameterisation.

Parameters:
pre_rescalingstr 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.

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_rescalingstr 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.

pre_rescaling(x)

Function applied before rescaling to bounds

pre_rescaling_inv(x)

Inverse of function applied before rescaling to bounds

post_rescaling(x)

Function applied after rescaling to bounds

post_rescaling_inv(x)

Inverse of function applied after rescaling to bounds

reparameterise(x, x_prime, log_j, compute_radius=False, **kwargs)

Rescale inputs to the prime space

Parameters:
x, x_primearray_like

Arrays of samples in the physical and prime space

log_jarray_like

Array of values of log-Jacobian

compute_radiusbool, optional

If true force duplicate for inversion

kwargs

Parsed to inversion function

inverse_reparameterise(x, x_prime, log_j, **kwargs)

Map inputs to the physical space from the prime space

reset_inversion()

Reset the edges for inversion

set_bounds(prior_bounds)

Set the initial bounds for rescaling

update_bounds(x)

Update the bounds used for the reparameterisation

update_prime_prior_bounds()

Update the prior bounds used for the prime prior

update(x)

Update the reparameterisation given some points.

Includes resetting the inversions and updating the bounds.

x_prime_log_prior(x_prime)

Compute the prior in the prime space assuming a uniform prior