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: spectra : array-like
The input spectral flux, assumed to have a common wavelength and redshift system.
invvar : array-like
The inverse variance of the spectral flux.
K :
int
, optionalThe number of dimensions of the factorization (default 4).
n_iter :
int
, optionalNumber of iterations.
seed :
int
, optional.If set, pass this value to
numpy.random.seed()
.nonnegative :
bool
, optionalSet this to
True
to perform nonnegative HMF.epsilon :
float
, optionalRegularization parameter. Set to any non-negative float value to turn it on.
verbose :
bool
, optionalIf
True
, print extra information.Notes
See [R1] and [R2] 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
[R1] (1, 2) Tsalmantza, P., Decarli, R., Dotti, M., Hogg, D. W., 2011 ApJ 738, 20 [R2] (1, 2) Tsalmantza, P., Hogg, D. W., 2012 ApJ 753, 122 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