HMF¶
- class pydl.pydlspec2d.spec1d.HMF(spectra, invvar, K=4, n_iter=None, seed=None, nonnegative=False, epsilon=None, verbose=False)[source]¶
Bases:
object
Class used to manage data for Heteroscedastic Matrix Factorization (HMF).
This is a replacement for
pca_solve()
. It can be called with:hmf = HMF(spectra, invvar) output = hmf.solve()
The input spectra should be pre-processed through
combine1fiber()
.- Parameters
- spectraarray-like
The input spectral flux, assumed to have a common wavelength and redshift system.
- invvararray-like
The inverse variance of the spectral flux.
- K
int
, optional The number of dimensions of the factorization (default 4).
- n_iter
int
, optional Number of iterations.
- seed
int
, optional. If set, pass this value to
numpy.random.seed()
.- nonnegative
bool
, optional Set this to
True
to perform nonnegative HMF.- epsilon
float
, optional Regularization parameter. Set to any non-negative float value to turn it on.
- verbose
bool
, optional If
True
, print extra information.
Notes
See [1] and [2] for the original derivation of this method.
The HMF iteration is initialized using
kmeans()
, which itself uses random numbers to initialize its state. If you need to ensure reproducibility, callnumpy.random.seed()
before initializing HMF.The current algorithm cannot handle input data that contain columns of zeros. Columns of this type need to be carefully removed from the input data. This could also result in the output data having a different size compared to the input data.
References
Methods Summary
astep
()Update for coefficients at fixed component spectra.
astepnn
()Non-negative update for coefficients at fixed component spectra.
badness
()Compute \(\chi^2\), including possible non-smoothness penalty.
chi
()Compute \(\chi\), the scaled residual.
gstep
()Update for component spectra at fixed coefficients.
gstepnn
()Non-negative update for component spectra at fixed coefficients.
iterate
()Handle the HMF iteration.
model
()Compute the model.
normbase
()Apply standard component normalization.
penalty
()Compute penalty for non-smoothness.
reorder
()Reorder and rotate basis analogous to PCA.
resid
()Compute residuals.
solve
()Process the inputs.
Methods Documentation