fabada icon indicating copy to clipboard operation
fabada copied to clipboard

chi2pdf

Open falseywinchnet opened this issue 3 years ago • 0 comments

https://github.com/PabloMSanAla/fabada/blob/44a0ae025d21a11235f6591f8fcacbf7c0cec1ec/fabada/init.py#L129

The chi2pdf estimation is dependent on df. df, in the example demos, is set to data.size.

In the case of fabada_demo_spectrum, data.size is 1430 samples.

per wolfram alpha, the gamma function value of 715 is 1x10^1729, which is well out of the calculation range of any desktop computer.

chi2_data = np.sum <-- a float chi2_pdf = stats.chi2.pdf(chi2_data, df=data.size)

https://lost-contact.mit.edu/afs/inf.ed.ac.uk/group/teaching/matlab-help/R2014a/stats/chi2pdf.html

chi2_pdf = (chi2data** (N - 2) / 2) * numpy.exp(-chi2sum / 2)
/ ((2 ** (N / 2)) * math.gamma(N / 2))

As a result, this function is going to fail without any question, and numpy /python will happily ignore the NaN value which is always returned. this then turns chi2_pdf_derivative chi2_pdf_previous chi2_pdf_snd_derivative chi2_pdf_derivative_previous into NaN values as well.

falseywinchnet avatar May 17 '22 02:05 falseywinchnet