idmtools_calibra.utilities.prior module

class idmtools_calibra.utilities.prior.SampleRange(range_type, range_min, range_max)[source]

Bases: object

Container for min, max of a range and a type of sampling to use

Parameters:
  • range_type – Type of sampling within range. Supported values: linear, log, linear_int

  • range_min – Minimum of sampling range.

  • range_max – Maximum of sampling range.

get_sample_function()[source]

Converts sample-range variables into scipy.stats frozen function :return: Frozen scipy.stats function

get_bins(n)[source]
get_xlim()[source]
is_log()[source]
is_int()[source]
class idmtools_calibra.utilities.prior.SampleFunctionContainer(function, sample_range=None)[source]

Bases: object

Container for a frozen function and optionally its associated sample-range properties

classmethod from_range(sample_range)[source]
classmethod from_tuple(*args)[source]
get_even_spaced_samples(n)[source]

Returns an evenly spaced sampling of the percent-point function (inverse CDF) :param n: number of evenly spaced samples

pdf(X)[source]

Wrapper for contained function pdf with check for discrete distributions :return:

class idmtools_calibra.utilities.prior.MultiVariatePrior(functions, params=[], ranges=[], name=None)[source]

Bases: object

Multi-variate wrapper exposing same interfaces as scipy.stats functions, i.e. pdf and rvs

Different dimensions are drawn independently from the univariate distributions.

Parameters:
  • sample_functions – list of scipy.stats frozen functions

  • params – list of parameter names associated with functions (optional)

  • ranges – list of SampleRange objects associated with functions (optional)

  • name – name of MultiVariatePrior object (optional)

property functions
property params
property ndim
classmethod by_range(**param_sample_ranges)[source]

Builds multi-variate wrapper from keyword arguments of parameter names to SampleRange (min, max, type)

Parameters:

param_sample_ranges – keyword arguments of parameter names to SampleRange tuple

Returns:

MultiVariatePrior instance

An example usage:

> prior = MultiVariatePrior.by_range(
      MSP1_Merozoite_Kill_Fraction=('linear', 0.4, 0.7),
      Max_Individual_Infections=('linear_int', 3, 8),
      Base_Gametocyte_Production_Rate=('log', 0.001, 0.5))
classmethod by_param(**param_sample_functions)[source]

Builds multi-variate wrapper from keyword arguments of parameter names to univariate frozen functions

Parameters:

param_sample_functions – keyword arguments of parameter names to univariate object supporting pdf and rvs interfaces

Returns:

MultiVariatePrior instance

An example usage:

> from scipy.stats import uniform
> prior = MultiVariatePrior.by_param(
      MSP1_Merozoite_Kill_Fraction=uniform(loc=0.4, scale=0.3),  # from 0.4 to 0.7
      Nonspecific_Antigenicity_Factor=uniform(loc=0.1, scale=0.8))  # from 0.1 to 0.9
pdf(X)[source]

Returns product of individual component function PDFs at each input point.

Parameters:

X – array of points, where each point is an array of correct dimension.

rvs(size=1)[source]

Returns an array of random points, where each point is sampled randomly in its component dimensions.

Parameters:

size – the number of random points to sample.

lhs(size=1)[source]

Returns a Latin Hypercube sample, drawn from the sampling ranges of the component dimensions :param size: the number of random points to sample

to_dataframe(param_value_array)[source]

Transforms an array of parameter-value arrays to a pandas.DataFrame with appropriate column names

to_dict(param_point)[source]

Transforms an individual point in parameter space to a dictionary of parameter names to values. Also will round parameters where the range_type requires integer-only values.