distributions.discrete_multiparameter¶
Module: distributions.discrete_multiparameter
¶
Inheritance diagram for selectinf.distributions.discrete_multiparameter
:
This module contains a class for discrete multiparameter exponential families. The main use for this is (post-selection) maximum likelihood estimation.
Unlike the single parameter family, we do not provide tools for exact hypothesis tests and selection intervals.
Approximate (Wald) tests and intervals are possible after estimation.
multiparameter_family
¶
-
class
selectinf.distributions.discrete_multiparameter.
multiparameter_family
(sufficient_stat, weights)[source]¶ Bases:
object
-
__init__
(sufficient_stat, weights)[source]¶ A discrete multi-parameter dimensional exponential family with reference measure \(\sum_j w_j \delta_{X_j}\) and sufficient statistic sufficient_stat. For any \(\theta\), the distribution is
\[P_{\theta} = \sum_{j} e^{\theta X_j - \Lambda(\theta)} w_j \delta_{X_j}\]where
\[\Lambda(\theta) = \log \left(\sum_j w_j e^{\theta X_j} \right).\]- Parameters
sufficient_stat : np.float((n,k))
weights : np.float(n)
Notes
The weights are normalized to sum to 1.
-
property
theta
¶ The natural parameter of the family.
-
property
partition
¶ Partition function at self.theta:
\[\sum_j e^{\theta X_j} w_j\]
-
property
sufficient_stat
¶ Sufficient statistics of the exponential family.
-
property
weights
¶ Weights of the exponential family.
-
pdf
(theta)[source]¶ Density of \(P_{\theta}\) with respect to \(P_0\).
- Parameters
theta : float
Natural parameter.
- Returns
pdf : np.float
-
E
(theta, func)[source]¶ Expectation of func under \(P_{\theta}\)
- Parameters
theta : float
Natural parameter.
func : callable
Assumed to be vectorized.
gamma : float(optional)
Weight given at x.
- Returns
E : np.float
-
Var
(theta, func)[source]¶ Variance of func under \(P_{\theta}\)
- Parameters
theta : float
Natural parameter.
func : callable
Assumed to be vectorized.
- Returns
var : np.float
-
Cov
(theta, func1, func2)[source]¶ Covariance of func1 and func2 under \(P_{\theta}\)
- Parameters
theta : float
Natural parameter.
func1, func2 : callable
Assumed to be vectorized.
- Returns
cov : np.float
-
mean
(theta)[source]¶ Mean parameter of family at natural parameter theta.
- Parameters
theta : np.float(k)
Natural parameter.
- Returns
mean : np.float(k)
Expected value of sufficient statistic at theta.
-
information
(theta)[source]¶ Compute mean and Fisher information of family at natural parameter theta.
- Parameters
theta : np.float(k)
Natural parameter.
- Returns
mean : np.float(k)
Expected value of sufficient statistic at theta.
information : np.float((k,k))
Covariance matrix of sufficient statistic at theta.
-
MLE
(observed_sufficient, min_iters=3, max_iters=20, tol=1e-06, initial=None)[source]¶ Compute mean and Fisher information of family at natural parameter theta.
- Parameters
observed_sufficient : np.float(k)
Observed sufficient statistic.
min_iters : int
Minimum number of Newton steps.
max_iters : int
How many Newton steps?
tol : float
Relative tolerance for objective value.
- Returns
theta_hat : np.float(k)
Maximum likelihood estimate.
-