Professor-G / MicroLIA

Gravitational microlensing classification engine using machine learning
GNU General Public License v3.0
12 stars 6 forks source link

Fixing the derivative of the times series #24

Closed romanovzky closed 9 months ago

romanovzky commented 9 months ago

Hi there,

I've created a PR here https://github.com/Professor-G/MicroLIA/pull/23 that fixes two errors regarding the derivative of the time series:

1) It fixes how the error is propagated to the derivative of the time series. The original implementation is not the proper error propagation. If one has the derivative of the time series

$$ g = \frac{d x}{d t} $$

where $x$ has error bars $\sigma_x$, then the propagation of error is

$$ \sigma_g^2 = \left( \frac{d g}{d x} \right)^2 \sigma_x^2 $$

using the chain rule and the derivative of the inverse function, this can be written as

$$ \sigma_g^2 = \left( \frac{d t}{d x} \frac{d g}{d t} \right)^2 \sigma_x^2 = \left( \frac{d g}{d t} / \frac{d x}{d t} \right)^2 \sigma_x^2 = \left( \frac{d g}{d t} /g\right)^2 \sigma_x^2 $$

2) The usage of the derivative of the time series produces NaN for two reasons: there might be duplicated timestamps in the time-series (see OGLEII timestamps), or there might be points with $g=0$. To fix this, one can use masks to constrain to finite values of $g$ and its error. This is what fix 2 does.

With this I removed virtually all the NaN, I'm now working on a fix for another source of NaN.

Professor-G commented 9 months ago

Thank you for this, this was a problem I noticed even in the simulated lightcurves and I could not figure it out. Cheers!