stacie.cost module

Cost function to optimize models for the low-frequency part of the spectrum.

class LowFreqCost(freqs, ndofs, amplitudes, weights, model)[source]

Bases: object

Cost function to fit a model to the low-frequency part of the spectrum.

Parameters:
amplitudes: ndarray[tuple[Any, ...], dtype[float]]

The actual spectrum amplitudes at frequencies in self.freqs.

expected(pars)[source]

Compute the expected value and variance of the cost function.

Parameters:

pars (ndarray[tuple[Any, ...], dtype[float]]) – The model parameters. Vectorization is not supported yet.

Return type:

ndarray[tuple[Any, ...], dtype[float]]

Returns:

expected, variance – The expected value and variance of the cost function.

freqs: ndarray[tuple[Any, ...], dtype[float]]

The frequencies for which the spectrum amplitudes are computed.

model: SpectrumModel

The model to be fitted to the spectrum.

ndofs: ndarray[tuple[Any, ...], dtype[int]]

The number of independent contributions to each spectrum amplitude.

weights: ndarray[tuple[Any, ...], dtype[float]]

The fitting weights for each grid point.

entropy_gamma(alpha, theta, *, deriv=0)[source]

Compute the entropy of the Gamma distribution.

Parameters:
Returns:

results – A list of results (function value and requested derivatives.) All elements have the same shape as the alpha and theta arrays.

logpdf_gamma(x, alpha, theta, *, deriv=0)[source]

Compute the logarithm of the probability density function of the Gamma distribution.

Parameters:
Returns:

results – A list of results (function value and requested derivatives.) All elements have the same shape as the theta array.

varlogp_gamma(alpha)[source]

Compute the variance of the log-probability density function of the Gamma distribution.

Parameters:

alpha (ndarray[tuple[Any, ...], dtype[float]]) – The shape parameter.

Return type:

ndarray[tuple[Any, ...], dtype[float]]

Returns:

var – The variance of the log-probability density function. Array with shape (alpha,).