StingraySoftware / stingray

Anything can happen in the next half hour (including spectral timing made easy)!
https://stingray.science/stingray
MIT License
172 stars 141 forks source link

Errors in rms_calculation are incorrect #790

Closed matteobachetti closed 8 months ago

matteobachetti commented 8 months ago

When simulating many times a PDS with a given rms and measuring it with our rms_calculation in fourier.py, the error bars are underestimated (red lines indicate the calculated error, the blue ones the actual standard deviation of the measurements in the thousands of realization) image

I re-implemented the method from scratch, using clearer passages to normalize the spectrum correctly, and I obtain something like this: image

So, there must be an error somewhere. Since the current code is rather clunky, I'm inclined to deprecate the old function and create a new one with clearer parameters (e.g. making it clear whether a parameter refers to the full observation or each segment of the averaged spectrum, like nphots_per_segment)