truncated.chi

Module: truncated.chi

Inheritance diagram for selectinf.truncated.chi:

digraph inheritance3a841d7ae8 { rankdir=LR; size="8.0, 12.0"; "truncated.base.truncated" [URL="selectinf.truncated.base.html#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"]; "truncated.chi.truncated_chi" [URL="#selectinf.truncated.chi.truncated_chi",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip=">>> from selectinf.constraints.intervals import intervals"]; "truncated.base.truncated" -> "truncated.chi.truncated_chi" [arrowsize=0.5,style="setlinewidth(0.5)"]; "truncated.chi.truncated_chi2" [URL="#selectinf.truncated.chi.truncated_chi2",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip=">>> from selectinf.constraints.intervals import intervals"]; "truncated.base.truncated" -> "truncated.chi.truncated_chi2" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

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

Classes

truncated_chi

class selectinf.truncated.chi.truncated_chi(I, k, scale=1.0)[source]

Bases: selectinf.truncated.base.truncated

>>> from selectinf.constraints.intervals import intervals
>>> I = intervals.intersection(intervals((-1, 6)),
...                            intervals(( 0, 7)),
...                           ~intervals((1, 4)))
>>> distr = truncated_chi(I, 3, 2.)
>>> print(abs(distr.cdf(distr.quantile(0.9)) - 0.9) < 0.01)
True
__init__(I, k, scale=1.0)[source]

Create a new object for a truncated_chi distribution

Parameters

I : intervals

The intervals the distribution is truncated to

k : int

Number of degree of freedom of the distribution

scale : float

The distribution is sim scale * chi_k

cdf(z)

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)

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)
rvs(size=1)

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)

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 )

truncated_chi2

class selectinf.truncated.chi.truncated_chi2(I, k, scale=1.0)[source]

Bases: selectinf.truncated.base.truncated

>>> from selectinf.constraints.intervals import intervals
>>> I = intervals.intersection(intervals((-1, 6)),
...                            intervals(( 0, 7)),
...                           ~intervals((1, 4)))
>>> distr = truncated_chi2(I, 3, 2.)
>>> print(abs(distr.cdf(distr.quantile(0.9)) - 0.9) < 0.01)
True
__init__(I, k, scale=1.0)[source]

Create a new object for a truncated_chi distribution

Parameters

I : intervals

The intervals the distribution is truncated to

k : int

Number of degree of freedom of the distribution

scale : float

The distribution is sim scale * chi_k

cdf(z)

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)

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)
rvs(size=1)

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)

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 )