glearn.priors.Uniform.suggest_hyperparam#

Uniform.suggest_hyperparam(positive=False)#

Find an initial guess for the hyperparameters based on the peaks of the prior distribution.

Parameters:
positivebool, default=False

If True, it suggests a positive hyperparameter. This is used for instance if the suggested hyperparameter is used for the scale parameter which should always be positive.

Returns:
hyperparamfloat or numpy.array[float]

A feasible guess for the hyperparameter. The output is either a scalar or an array of the same size as the input parameters of the distribution.

Notes

For the uniform distribution in the interval \([a, b]\), the suggested hyperparameter is the mid-point of the interval, \(\theta = (a+b)/2\).

If the input arguments a and b are given as the arrays \(\boldsymbol{a} = (a_1, \dots, a_p)\) and \(\boldsymbol{b} = (b_1, \dots, b_p)\), the suggested array of hyperparameters \(\boldsymbol{\theta} = (\theta_1, \dots, \theta_p)\) are \(\theta_i = (a_i + b_i) / 2\).

The suggested hyperparameters can be used as initial guess for the optimization of the posterior functions when used with this prior.

Examples

Create uniform prior in the interval \([0.2, 0.9]\):

>>> from glearn import priors
>>> prior = priors.Uniform(0.2, 0.9)

>>> # Find a feasible hyperparameter value
>>> prior.suggest_hyperparam()
array([0.55])

The above value is the mid-point of the interval \([0.2, 0.9]\).