LHCfitNikhef / smefit_release

SMEFiT a Standard Model Effective Field Theory fitter
GNU General Public License v3.0
6 stars 1 forks source link

Analytic solution to linear problem #60

Closed LucaMantani closed 9 months ago

LucaMantani commented 9 months ago

I think it would be nice to have an analytic solution module to solve the linear problem. This could be realised in the following way:

chi2 = (D - T_SM - X c). Sigma.(D - T_SM - X c) = (Y - X c).Sigma.(Y - X c)

D = data (array) T_SM = SM_best (array) X = matrix of EFT predictions (n_data, n_coeffs) c = array of wilson coefficients Sigma = inverse cov mat Y = D- T_SM

The posterior is a gaussian, with parameters:

mean = np.inv(X.T @ Sigma @ X) @ X.T @ Sigma @ Y
covmat = np.inv(X.T @ Sigma @ X)

Then we could generate posterior samples with:

samples = np.random.multivariate_normal(
        weights_mean,
        weights_covmat,
        size=(N_samples, ),
    )

This way we can interface the output of the module to the same identical routines of NS and we don't have to reinvent the wheel.

giacomomagni commented 9 months ago

Hi @LucaMantani, this seems doable we can add an option. Do I understand correctly that the best fit solutions, will be the mean on all the datapoints of this matrix?

np.inv(X.T @ Sigma @ X) @ X.T @ Sigma @ Y
LucaMantani commented 9 months ago

Hi @giacomomagni , yes, the best fit solution will be the mean of the gaussian.