bilby.core.sampler.ptemcee.get_max_gradient

bilby.core.sampler.ptemcee.get_max_gradient(x, axis=0, window_length=11, polyorder=2, smooth=False)[source]

Calculate the maximum value of the gradient in the input data.

Applies a Savitzky-Golay filter (scipy.signal.savgol_filter) to the input data x, along a particular axis. This filter smooths the data and, as configured in this function, simultaneously calculates the derivative of the smoothed data. If smooth=True is provided, it will apply a Savitzky-Golay filter with a polynomial order of 3 to the input data before applying this filter a second time and calculating the derivative. This function will return the maximum value of the derivative returned by the filter.

See https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.savgol_filter.html for more information on the Savitzky-Golay filter that we use. Some parameter documentation has been borrowed from this source.

Parameters:
xnp.ndarray

Array of input data (can be int or float, as savgol_filter casts to float).

axisint, default = 0

The axis of the input array x over which to calculate the gradient.

window_lengthint, default = 11

The length of the filter window (i.e., the number of coefficients to use in approximating the data).

polyorderint, default = 2

The order of the polynomial used to fit the samples. polyorder must be less than window_length.

smoothbool, default = False

If true, this will smooth the data with a Savitzky-Golay filter before providing it to the Savitzky-Golay filter for calculating the derviative. Probably useful if you think your input data is especially noisy.

Returns:
max_gradientfloat

Maximum value of the gradient.