SasView / sasview

Code for the SasView application.
BSD 3-Clause "New" or "Revised" License
49 stars 41 forks source link

Error propagation is incorrect for the Porod plot #2990

Open butlerpd opened 1 month ago

butlerpd commented 1 month ago

Describe the bug The Error bars blow up completely wrong at higher Q^4 when using a linearized Porod plot.

To Reproduce Steps to reproduce the behavior: Load a 1D data set, plot it, change scale to Porod. Those error bars are demonstrably wrong.

Expected behavior They should be correct. Visually that means they they need to be slightly smaller than the jitter in the data (definition of 1 sigma being 68% confidence level?)

SasView version (please complete the following information):

Operating system (please complete the following information):

Additional context Interestingly this does NOT seem to be an issue for the Guinier plot? but is for the Kratky plot

lucas-wilkins commented 1 month ago

Will look at this.

definition of 1 sigma being 68% confidence level?

If this is a direct question, then yes, for a two tailed gaussian CI, +- 1sigma is about 68%. If you mean should the error bars be set to 1 sigma, then that's a different matter. I would have the preference of 95% - 2.something sigma - for most general applications. Is there a standard for the community?

andyfaff commented 1 month ago

I would expect uncertainties to be quoted as +/- 1sigma

lucas-wilkins commented 1 month ago

There appears to be a few issues with the transformation system, not just this.

lucas-wilkins commented 1 month ago

@butlerpd The errors appear to be correct. The reason why get big is that the error in the x axis (i.e. resolution) is also propagated though, and as the new y axis is yx^4 the new y axis gains errors that you couldn't see previously.

I consider this to be the correct behaviour.

There was however a bug in the units which I have fixed.

butlerpd commented 1 month ago

Sorry -- I missed this somehow.

Thanks for the explanation. Now I see the error! I was confused as to how it got there, but am now reopening the ticket.

However that would definitely not be the correct behavior. Resolution is not an uncertainty. That is in fact the prime example I use when trying to explain the difference between resolution and uncertainty: they dot not propagate in the same way. In fact a look at a plot makes it clear that the error bar on y cannot possibly be 1 sigma. For that to be true, the straight line fit should be outside 30% of the error bars. As it is, they are within all within a few percent of the center of all error bars. Whether resolution needs to be taken into account when calculating the slope and intercept is another questions. Probably? but from what I can tell, at least for pinhole resolution, it doesn't seem to matter?

butlerpd commented 1 month ago

I'm not sure this should be a SasView 6 item but am labeling it so as agreed on Tuesday as the starting place for all NIST CNR summer school generated issues.