pynbody / genetIC

The GM initial conditions generator
GNU General Public License v3.0
21 stars 8 forks source link

Chi square calculation #30

Closed Martin-Rey closed 6 years ago

Martin-Rey commented 6 years ago

Following our discussion, I have been looking at the chi square calculation.

The method historically used for chi^2 calculation looked like this: https://github.com/ucl-cosmoparticles/genetIC/blob/a04d1188450880974ef48a63e02532240bd94b61/genetIC/src/simulation/field/multilevelfield.hpp#L323-L341

I refactored it into the ability to transform a vector to convector ( by dividing by the covariance matrix in fourier space) to look like this: https://github.com/ucl-cosmoparticles/genetIC/blob/3b337c37075ca50b91d76519e1d4ba9f5b017162/genetIC/src/simulation/field/multilevelfield.hpp#L325-L334

The two method differ for the following reasons:

Even though the recent method is neater in mathematical term, it creates an unneeded copy of the field so it might be worth going back to the old version.

Martin-Rey commented 6 years ago

Quick question, could the 1/n factor in the old implementation be a FFT norm factor ? The calculation was always assumed to be performed in Fourier space.

apontzen commented 6 years ago

Could be. In principle it should be possible to figure this out by looking at the git history, but I'd suggest instead just going for the approach of getting an implementation that passes the chi^2~DOF test for the initial random field.