truncated.gaussian¶
Module: truncated.gaussian
¶
Inheritance diagram for selectinf.truncated.gaussian
:
This module implements the class truncated_gaussian which performs (conditional) UMPU tests for Gaussians restricted to a set of intervals.
Classes¶
truncated_gaussian
¶
-
class
selectinf.truncated.gaussian.
truncated_gaussian
(I, mu=0, 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_gaussian(I, 3.1, 2.)
-
__init__
(I, mu=0, scale=1.0)[source]¶ Create a new object for a truncated_gaussian distribution
- Parameters
I : intervals
The intervals the distribution is truncated to.
mu : int
Mean of Gaussian that is truncated.
scale : float
SD of Gaussian that is truncated.
-
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_gaussian_old
¶
-
class
selectinf.truncated.gaussian.
truncated_gaussian_old
(intervals, mu=0, scale=1)[source]¶ Bases:
object
A Gaussian distribution, truncated to
-
__init__
(intervals, mu=0, scale=1)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
intervals
¶
-
property
negated
¶
-
property
mu
¶
-
property
scale
¶
-
property
delta
¶ - \[\begin{split}\begin{align} \delta_\mu(a,b) &\triangleq \int_a^b x\phi(x-\mu)\,dx \\ &= - \phi(b-\mu) + \phi(a-\mu) + \mu\left(\Phi(b-\mu)-\Phi(a-\mu)\right), \end{align}\end{split}\]
-
Functions¶
-
selectinf.truncated.gaussian.
G
(left_endpoints, mus, alpha, tg)[source]¶ Compute the \(G\) function of tg(intervals) over zip(left_endpoints, mus).
A copy is made of tg and its \((\mu,\scale)\) are not modified.