openest.models.spline_model module

class openest.models.spline_model.SplineModel(xx_is_categorical=False, xx=None, conditionals=None, scaled=True)[source]

Bases: openest.models.univariate_model.UnivariateModel, openest.models.memoizable.MemoizableUnivariate

Model Spline File

Each line in a model spline file represents a polynomial segment in log-probability space. The format is as follows:

spp1
<x>,<y0>,<y1>,<a0>,<a1>,<a2>
...

Each line describes a segment of a probability distribution of y, conditional on x = <x>. The segment spans from <y0> to <y1>, where the lowest value of <y0> may be -inf, and the highest value of <y1> may be inf. The <x> values may also be categorical or numerical. If they are numerical, it is assumed that these values represent samples of a smoothly varying function (a cubic spline in every y).

The values <a0>, <a1> and <a2> are the polynomial coefficients in y (with quadratic coefficients, only normal or exponential tails are possible). The final segment of the probability function is:

exp(a0 + a1 y + a2 y2)
Parameters:
  • xx_is_categorical (bool) –
  • xx (list-like) –
  • conditionals
  • scaled (bool) –
add_conditional(x, conditional)[source]
cdf(xx, yy)[source]
static combine(one, two)[source]
copy()[source]
static create_gaussian(xxs, order=None, xx_is_categorical=True)[source]

xxs should be a dictionary of the form {x: (mean, variance)}.

static create_single(xxs, y0s, y1s, coeffss, order=None, xx_is_categorical=True)[source]
draw_sample(x=None)[source]

Produce a sample value of y from the conditional distribution.

eval_pval(x, p, threshold=0.001)[source]

Inverse CDF Evaluation

Returns the value of $y$ that corresponds to a given p-value: $F^{-1}(p | x)$.

eval_pval_index(ii, p, threshold=0.001)[source]
filter_x(xx)[source]
static from_ddp(ddp_model, limits)[source]
get_conditional(x)[source]
get_mean(x=None)[source]

E[Y | X]

get_sdev(x=None)[source]

sqrt Var[Y | X]

get_xx()[source]

Listing conditional values

Provide a list of all sampled conditional values.

init_from_spline_file(file, delimiter, status_callback=None)[source]
interpolate_x(newxx)[source]

Determines whether argument newxx a subset of index xx.

is_gaussian(x=None)[source]
kind()[source]
static merge(models)[source]
neginf = -inf
posinf = inf
recategorize_x(oldxx, newxx)[source]

Construct a new model with categorical x values ‘newxx’, using the conditionals currently assigned to categorical x values ‘oldxx’.

samples = 1000
scale_p(a)[source]

Raise the distribution to the power ‘a’ and rescales.

Returns:modifies this model and returns it
Return type:self
scale_y(a)[source]

Rescaling of the Parameter Dimension

Produces a new conditional PDF with the $y$ dimension scaled by a constant: $p(z | x) = p( rac{y}{a} | x)$.

to_ddp(ys=None)[source]
to_points_at(x, ys)[source]

Conditional Probability Density Evaluation

Returns unscaled probability density values for given values of $x$ and $y$: $f(y | x)$.

write(file, delimiter)[source]
write_file(filename, delimiter)[source]
write_gaussian(file, delimiter)[source]
write_gaussian_plus(file, delimiter)[source]
class openest.models.spline_model.SplineModelConditional(y0s=None, y1s=None, coeffs=None)[source]
add_segment(y0, y1, coeffs)[source]
approximate_mean(limits)[source]
static approximate_sum(conditionals)[source]
static ascinv(y, func, minx, maxx, threshold)[source]
cdf(yy)[source]
convolve(other)[source]
copy()[source]
draw_sample()[source]
evaluate(ii, y)[source]
find_mode()[source]
static find_nearest(array, value, within)[source]
gaussian_mean(ii)[source]
gaussian_sdev(ii)[source]
get_pval(p, threshold=0.001)[source]
is_gaussian()[source]
static make_conditional_from_spline(spline, limits)[source]
static make_gaussian(y0, y1, mean, var)[source]
static make_single(y0, y1, coeffs)[source]
nongaussian_x2px(ii)[source]
nongaussian_xpx(ii)[source]
partial_cdf(ii, y1)[source]
static propose_grid(conditionals)[source]
rescale()[source]
rough_limits()[source]
rough_span()[source]
scale(factor)[source]
scale_p(a)[source]
scale_y(a)[source]
segment_max(jj)[source]
size()[source]
to_points(ys)[source]