schrodinger.application.matsci.uq_utils module

Utilities for uncertainty quantification.

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.uq_utils.X_BIAS_F(x)
schrodinger.application.matsci.uq_utils.check_property_sign(prop, points)

Return True if the property has the correct sign.

Parameters:
  • prop (float) – the property

  • points (list) – (x, y) pair tuples of data

Return type:

bool

Returns:

True if the property has the correct sign

schrodinger.application.matsci.uq_utils.get_nonzero_data(xs, ys)

Return nonzero data.

Parameters:
  • xs (list) – the domain

  • ys (list) – the range

Return type:

list, list

Returns:

the domain and range

schrodinger.application.matsci.uq_utils.get_bilinear_regions(original_data)

Gets the initial early and late regions such that the R squared values are maximized.

Parameters:

original_data (list) – contains pair tuples of data points

Return type:

tuple, tuple

Returns:

(min, max) tuples for early and late regions

schrodinger.application.matsci.uq_utils.get_points_in_region(data, region)

Determine which data points fall into a region given its lower and upper bound.

Parameters:
  • data (list) – contains pair tuples of data points

  • region (tuple) – a tuple containing the lower and upper boundaries points of the region

Returns:

all points within the region

Return type:

list

schrodinger.application.matsci.uq_utils.get_bilinear_regression(data)

Return the regression information.

Parameters:

data (list) – contains pair tuples of data points

Return type:

tuple

Returns:

(slope, intercept, R^2)

schrodinger.application.matsci.uq_utils.get_bilinear_prop(early_regression, late_regression)

Returns the bilinear property if both regressions are available.

Parameters:
  • early_regression (tuple) – (slope, intercept, R^2) for early part

  • late_regression (tuple) – (slope, intercept, R^2) for late part

Returns:

the property

Return type:

float

schrodinger.application.matsci.uq_utils.get_bilinear_fit_property(x, x_intersection, early_regression, late_regression, invert_y=True)

Return the fit property given the x-value.

Parameters:
  • x (float) – the x-value

  • x_intersection (float) – the x intersection point

  • early_regression (tuple) – (slope, intercept, R^2) for early part

  • late_regression (tuple) – (slope, intercept, R^2) for late part

  • invert_y (bool) – whether to invert the y-values

Return type:

float or None

Returns:

the fit property value or None if there isn’t one

schrodinger.application.matsci.uq_utils.get_bilinear_prop_from_points(points, early_region=None, late_region=None)

Return a bilinear property using the given points.

Parameters:
  • points (list) – list of (x,y) tuples

  • early_region (tuple or None) – (min, max) tuple for early region, if None then automatically determined

  • late_region (tuple or None) – (min, max) tuple for late region, if None then automatically determined

Return type:

float or None

Returns:

the property or None if there isn’t one

schrodinger.application.matsci.uq_utils.get_min_max_avg(data)

Return (min, max, avg) of the given data.

Parameters:

data (list) – the data

Return type:

float, float, float

Returns:

the min, max, avg

schrodinger.application.matsci.uq_utils.get_hyperbola_regression(data, avg_x)

Return the regression information.

Parameters:
  • data (list) – contains pair tuples of data points

  • avg_x (float) – the average x-value

Return type:

tuple

Returns:

(t0, a, b, c, p0) parameters

schrodinger.application.matsci.uq_utils.calc_property(x_scaled, t0, a, b, c, p0)

Calculate the hyperbolic property.

Parameters:
  • x_scaled (float) – the scaled x-value

  • t0 (float) – the scaled T_0 factor in polynomial

  • a (float) – a factor in polynomial

  • b (float) – b factor in polynomial

  • c (float) – c factor in polynomial

  • p0 (float) – p_0 factor in polynomial

schrodinger.application.matsci.uq_utils.get_hyperbola_fit_property(x, regression)

Return the fit property given the x-value.

Parameters:
  • x (float) – the x-value

  • regression (tuple) – (t0, a_coeff, b_coeff, c_coeff, p0)

Return type:

float or None

Returns:

the fit property value or None if there isn’t one

schrodinger.application.matsci.uq_utils.get_hyperbola_prop_from_points(points)

Return a hyperbola property using the given points.

Parameters:

points (list) – list of (x,y) tuples

Return type:

float or None

Returns:

the property or None if there isn’t one

class schrodinger.application.matsci.uq_utils.BootstrapNoiseHistogramData

Bases: object

Manage data of a histogram of a quantity derived from a parametric bootstrap analysis of uncorrelated Gaussian white noise.

SAMPLE_SIZE = 1000
__init__()

Create an instance.

setOriginalData(points)

Set the original data used to derive the histogram.

Parameters:

points (list) – list of (x,y) tuples

setFitFunction(fit_function)

Set the fit function, i.e. the function that was fit to the original data.

Parameters:

fit_function (function) – the fit function

setXBiasFunction(x_bias_function=None)

Set a biasing function for the original x data.

Parameters:

x_bias_function (function or None) – a biasing function for the original x data or None if there isn’t one

seedRandom(seed=None)

Seed the random number generator.

Parameters:

seed (int or None) – the seed

setSampleSize(size=None)

Set the sample size.

Parameters:

size (int or None) – the sample size, if None then the default of SAMPLE_SIZE is used

setTargetFunction(target_function)

Set the target function, i.e. the function used to obtain the target quantity from points.

Parameters:

target_function (function) – the target function

getHistogramData()

Return the histogram data which is just a list of sampled target values.

Raises:

RuntimeError – if required variables are not defined

Return type:

list or None

Returns:

list of sampled target values or None if there isn’t one

static getSampleHistogram(points, fit_function, target_function, x_bias_function=None, seed=None, size=None)

Return a sample of histogram data using the given points, fit function, and target function.

Parameters:
  • points (list) – list of (x,y) tuples

  • fit_function (function) – the fit function

  • target_function (function) – the target function

  • x_bias_function (function or None) – a biasing function for the original x data or None if there isn’t one

  • seed (int or None) – the seed

  • size (int or None) – the sample size, if None then the default of SAMPLE_SIZE is used

Return type:

list or None

Returns:

list of sampled target values or None if there isn’t one

static getNormalParameters(data)

Return the mean, standard deviation, covariance matrix, and figure of merit parameters from a normal fit of the given data.

Parameters:

data (list) – contains (x, y) tuples

Return type:

float, float, numpy.array, float or None, None, None, and None

Returns:

the mean, standard deviation, covariance matrix, and figure of merit or None, None, None, and None if there aren’t any

class schrodinger.application.matsci.uq_utils.BilinearHistogramData(invert_y=True)

Bases: BootstrapNoiseHistogramData

Manage a histogram using bilinear data.

__init__(invert_y=True)

Create an instance.

Parameters:

invert_y (bool) – whether to invert the y-values

static getSampleHistogram(points, fit_function, target_function, x_bias_function=None, seed=None, size=None, invert_y=True)

Return a sample of histogram data using the given points, fit function, and target function.

Parameters:
  • points (list) – list of (x,y) tuples, if using invert_y then this data should be uninverted

  • fit_function (function) – the fit function, if using invert_y then expected to return uninverted data

  • target_function (function) – the target function, if using invert_y then expects the input data to already be inverted

  • x_bias_function (function or None) – a biasing function for the original x data or None if there isn’t one

  • seed (int or None) – the seed

  • size (int or None) – the sample size, if None then the default of SAMPLE_SIZE is used

  • invert_y (bool) – whether to invert the y-values

Return type:

list or None

Returns:

list of sampled target values or None if there isn’t one

class schrodinger.application.matsci.uq_utils.HyperbolaHistogramData

Bases: BootstrapNoiseHistogramData

Manage a histogram using hyperbola data.

static getSampleHistogram(points, fit_function, target_function, x_bias_function=None, seed=None, size=None)

Return a sample of histogram data using the given points, fit function, and target function.

Parameters:
  • points (list) – list of (x,y) tuples

  • fit_function (function) – the fit function

  • target_function (function) – the target function

  • x_bias_function (function or None) – a biasing function for the original x data or None if there isn’t one

  • seed (int or None) – the seed

  • size (int or None) – the sample size, if None then the default of SAMPLE_SIZE is used

Return type:

list or None

Returns:

list of sampled target values or None if there isn’t one