truncated.base

Module: truncated.base

Inheritance diagram for selectinf.truncated.base:

digraph inheritanceb98e752542 { rankdir=LR; size="8.0, 12.0"; "truncated.base.truncated" [URL="#selectinf.truncated.base.truncated",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A distribution, truncated to a union of intervals"]; }

This module implements the class truncated_gaussian which performs (conditional) UMPU tests for Gaussians restricted to a set of intervals.

truncated

class selectinf.truncated.base.truncated(intervals)[source]

Bases: object

A distribution, truncated to a union of intervals

HOW TO MAKE A SUBCLASS : You have to implement :

__init__(self, args*)It has to call the method from the base class

Since the method is abstract, you can’t have an instance of the subclass if the method __init__ is not implemented

_cdf_notTruncated(self, a, b, dps) :

With these two methods, you can use

-> cdf -> sf

You should implement :

_pdf_notTruncated(self, z, dps)it allows you to use

-> pdf -> plt_pdf (if you also have _quantile_notTruncated)

_quantile_notTruncated(self, q, tol)it allows you to use

-> quantile -> rvs -> plt_cdf -> plt_pdf (if you also have _pdf_notTruncated)

abstract __init__(intervals)[source]

Create a new truncated distribution object This method is abstract : it has to be overriden

Parameters

intervals : [(float, float)]

The intervals the distribution is truncated to

rvs(size=1)[source]

Sample a random variable from the truncated disribution

Parameters

size : int

Number of samples. Default : 1

Returns

X : np.array

array of sample

sf(z)[source]

Compute the survival function of the truncated distribution

Parameters

z : float

Minimum bound of the interval

Returns

sf : float

The survival function of the truncated distribution sf(z) = P( X > z | X is in intervals )

cdf(z)[source]

Compute the survival function of the truncated distribution

Parameters

z : float

Minimum bound of the interval

Returns

cdf : float

function The cumulative distribution function of the truncated distribution cdf(z) = P( X < z | X is in intervals )

WARNING : This method only use the sf method

more precise

pdf(z)[source]

Compute the probability distribution funtion of the truncated distribution

Parameters

z : float

Returns

p : float

p(z) such that E[f(X)] = int f(z)p(z)dz

quantile(q, tol=1e-06)[source]
selectinf.truncated.base.find_root(f, y, lb, ub, tol=1e-06)[source]

searches for solution to f(x) = y in (lb, ub), where f is a monotone decreasing function