SourceXtractorPlusPlus icon indicating copy to clipboard operation
SourceXtractorPlusPlus copied to clipboard

Consider enabling the use of arrays (and matrix multiplications) in the definition of dependant parameters

Open rgavazzi opened this issue 3 years ago • 0 comments

Assuming you know beforehand that magnitude covariance (between n bands, say) are well captured by multivariate normal distribution N(v0, C) of central values v0, and covariance matrix C, and A^-1 is a lower triangular Choleski factorisation of C, it would be nice to enable the following definition of priors (this currently fails!).

# v0 and A, previously defined vector, and matrix, respectively

ZPT=23.9
flux={}
mag={}
centered_mag = {}
for band,group in mesgroup:
    flux[i] = get_flux_parameter()
    mag[i] = DependentParameter(lambda f: -2.5 * np.log10(f) + ZPT, flux[i] )
    centered_mag[i] = DependentParameter(lambda m:  m - v0[i], mag[i] )

eigen_mag = {}
for i in range(len(mag)):
  eigen_mag[i] = DependentParameter( lambda x: np.matmul(A,x)[i], centered_mag )
  add_prior( eigen_mag[i], 0.0, 1.0 )
  add_output_column('KK_'+str(i), eigen_mag[i])

Ideally, one would like to enable a definition of correlated multivariate Normal priors as simply as the following:

add_prior( mag, v0, C )

rgavazzi avatar Mar 04 '21 14:03 rgavazzi