smash-transport / sparkx

SPARKX - Software Package for Analyzing Relativistic Kinematics in Collision eXperiments
https://smash-transport.github.io/sparkx/
GNU General Public License v3.0
5 stars 0 forks source link

Histogram average gives wrong error #250

Closed NGoetz closed 2 months ago

NGoetz commented 2 months ago

The average function of Histogram is "grob falsch". The standard error is not calculated correctly. I would replace this function by calling average_weighted with unit weights (DRY!). We should investigate why this was not caught by tests.

NGoetz commented 2 months ago

The reason why the tests let that through is because we only check for the value, but not the error in the test for average. This is sad. Additionally, average_weighted is never tested as far as I can see.

Hendrik1704 commented 2 months ago

You mean this: self.error_ = np.sqrt(np.sum(self.histograms_, axis=0) / self.number_of_histograms_) is wrong? This is just the $\sqrt{N}$ of the averaged histograms assuming Poissonian statistics if I'm right.

NGoetz commented 2 months ago

I would have assumed to get the standard error just like for the average_weighted. The documentation claims that too. If we want a Poisson distributed error, that should be an optional argument, for both functions, and independently tested.

Hendrik1704 commented 2 months ago

The standard deviation for Poissonian statistics is $\sigma= \sqrt{N}$, so this statement is correct, at least for a single histogram.

NGoetz commented 2 months ago

It's correct for Poissonian, but the documentation says standard error. Isn't standard error also a more reasonable default?

Hendrik1704 commented 2 months ago

We should discuss with the others on Monday, what we want to put as a default.

NGoetz commented 2 months ago

I agree. An additional idea would be to add the option of error weighted average for weighted average right out of the box.

NGoetz commented 2 months ago

I think the standard error in the average_weighted is not even the standard error tbh. there is a factor missing.

NGoetz commented 2 months ago

raw_count is also not updated...? Bug or feature?