nessai.utils

General utilities for nessai.

Submodules

Package Contents

Classes

NessaiJSONEncoder

Class to encode numpy arrays and other non-serialisable objects.

Functions

get_multivariate_normal(dims[, var, device])

Return a Pytorch distribution that is normally distributed in n dims

get_uniform_distribution(dims, r[, device])

Return a torch distribution that is uniform in the number of dims

auto_bins(x[, max_bins])

Compute the number bins for a histogram using numpy.histogram_bin_edges

bonferroni_correction(p_values[, alpha])

Apply the Bonferroni correction for multiple tests.

compute_indices_ks_test(indices, nlive[, mode])

Compute the two-sided KS test for discrete insertion indices for a given

is_jsonable(x)

Check if an object is JSON serialisable.

safe_file_dump(data, filename, module[, save_existing])

Safely dump data to a .pickle file.

save_dict_to_hdf5(d, filename)

Save a dictionary to a HDF5 file.

save_live_points(live_points, filename)

Save live points to a file using JSON.

save_to_json(d, filename, **kwargs)

Save a dictionary to a JSON file.

setup_logger([output, label, log_level, ...])

Setup the logger.

configure_edge_detection(d, detect_edges)

Configure parameters for edge detection

detect_edge(x[, x_range, percent, cutoff, nbins, ...])

Detect edges in input distributions based on the density.

determine_rescaled_bounds(prior_min, prior_max, x_min, ...)

Determine the values of the prior min and max in the rescaled

inverse_rescale_minus_one_to_one(x, xmin, xmax)

Rescale from -1 to 1 to xmin to xmax

inverse_rescale_zero_to_one(x, xmin, xmax)

Rescale from 0 to 1 to xmin to xmax

logit(x[, eps])

Logit function that also returns log Jacobian determinant.

rescale_minus_one_to_one(x, xmin, xmax)

Rescale a value to -1 to 1

rescale_zero_to_one(x, xmin, xmax)

Rescale a value to 0 to 1

sigmoid(x)

Sigmoid function that also returns log Jacobian determinant.

compute_radius(n[, q])

Compute the radius that contains a fraction of the total probability in an n-dimensional unit Gaussian.

draw_gaussian(dims[, r, N, fuzz])

Wrapper for numpy.random.randn that deals with extra input parameters

draw_nsphere(dims[, r, N, fuzz])

Draw N points uniformly within an n-sphere of radius r

draw_surface_nsphere(dims[, r, N])

Draw N points uniformly from n-1 sphere of radius r using Marsaglia's

draw_truncated_gaussian(dims, r[, N, fuzz, var])

Draw N points from a truncated gaussian with a given a radius

draw_uniform(dims[, r, N, fuzz])

Draw from a uniform distribution on [0, 1].

compute_minimum_distances(samples[, metric])

Compute the distance to the nearest neighbour of each sample

rolling_mean(x[, N])

Compute the rolling mean with a given window size.

replace_in_list(target_list, targets, replacements)

Replace (in place) an entry in a list with a given element.

configure_threads([pytorch_threads])

Configure the number of threads available.

Attributes

rescaling_functions