Parameter estimation¶
ecopann.ann¶
ecopann.space_updater¶
-
class
ecopann.space_updater.Chains[source]¶ Bases:
object-
static
bestFit(chain, best_type='mode', out_sigma=1, symmetry_error=True)[source]¶ Get the best-fit parameters from the chain.
Parameters: - chain (array-like) – The ANN chain.
- best_type (str, optional) – The type of the best values of parameters, ‘mode’ or ‘median’. If ‘mode’, it will take the mode as the best value. If ‘median’, it will take the median as the best value. Default: ‘mode’
- out_sigma (int) – The output sigma, which can be 1, 2, or 3. Default: 1
- symmetry_error (bool, optional) – If True, obtain symmetrical errors, otherwise, obtain unsymmetrical errors. Default: True
-
static
cov_matrix(chain, max_error=True, expand_factor=0)[source]¶ Get the covariance matrix.
Parameters: - chain (array-like) – The ANN chain.
- max_error (bool, optional) – If True, the diagonal elements of the covariance matrix will be replaced by the estimated maximum errors, which is useful for non-Gaussian distribution. Default: True
- expand_factor (float, optional) – The expansion factor that is used to expand the error (the standard deviation) of each cosmological parameter. For example, if expand_factor=0.05, the error will has 5% expansion. It only works when max_error is True. Default: 0
Returns: cov – The covariance matrix.
Return type: array-like
-
static
error_devs(chain_1, chain_true)[source]¶ Get the absolute values of the relative deviations of error of parameters obtained from two chains.
-
static
sigma(chain, best_values, out_sigma=1)[source]¶ Calculate the standard deviations.
Parameters: - chain (array-like) – The ANN chain.
- best_values (1-dimension array) – The best values of parameters.
- out_sigma (int) – The output sigma, which can be 1, 2, or 3. Default: 1
Returns: - sigma_1l, sigma_2l, sigma_3l (1-dimension array) – The left 1 sigma, 2 sigma, or 3sigma deviations.
- sigma_1r, sigma_2r, sigma_3r (1-dimension array) – The right 1 sigma, 2 sigma, or 3sigma deviations.
-
static
-
class
ecopann.space_updater.CheckParameterSpace[source]¶ Bases:
object-
static
check_limit(p_space, limit_space)[source]¶ Check the parameter space to ensure that the parameter space does not exceed its limit range.
Parameters: - p_space (array-like) – The parameter space to be checked.
- limit_space (array-like) – The limit range of parameter space.
Returns: A parameter space being limited by its limit range.
Return type: array-like
-
static
-
class
ecopann.space_updater.UpdateParameterSpace(step, param_names, chain_1, chain_0=None, init_params=None, spaceSigma=5, params_dict=None)[source]¶ Bases:
ecopann.space_updater.CheckParameterSpaceUpdate parameter space.
Parameters: - step (int) – The number of step in the training process.
- param_names (list) – A list that contains parameter names.
- chain_1 (array-like) – The ANN chain of the i-th step, where \(i\geq2\).
- chain_0 (None or array-like, optional) – The ANN chain of the (i-1)-th step, where \(i\geq2\), if step \(\leq2\),
chain_0should be set to None, otherwise,chain_0should be an array. Default: None - init_params (None or array-like) – The initial settings of the parameter space. If
chain_0is given,init_paramswill be ignored. Default: None - spaceSigma (int or array-like, optional) – The size of parameter space to be learned. It is a int or a numpy array with shape of (n,), where n is the number of parameters, e.g. for spaceSigma=5, the parameter space to be learned is \([-5\sigma, +5\sigma]\). Default: 5
- params_dict (dict or None, optional) – Information of cosmological parameters that include the labels, the minimum values,
and the maximum values. See
params_dict_zoo(). Default: None
-
error_devs¶
-
param_devs¶
-
params_space()[source]¶ Obtain the parameter space to be learned from chain.
Returns: Limited parameter space. Return type: array-like
-
small_dev(limit_dev=0.01)[source]¶ A small value of deviation of parameters between two steps used to end the training process.
Parameters: limit_dev (float, optional) – If the deviation of parameters between two steps smaller than this value, the training process will be over. Default: 0.01 (the deviation < 1%) Returns: True (dev \(\leq\) limit_dev) or False (dev>limit_dev) Return type: bool
-
spaceSigma_all¶
-
spaceSigma_max¶
-
spaceSigma_min¶
-
ecopann.space_updater.get_CovMatrix(chain, params_n, best_values=None)[source]¶ Calculate covariance matrix from a chain.
Parameters: - chain (array-like) – The ANN or MCMC chain with shape (N, M), where N is the number of chain and M is the number of parameters.
- params_n (array-like) – The number of parameters.
- best_values (array-like) – The best-fit values.
Returns: cov_matrix – Covariance matrix.
Return type: array-like