-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[hist] Using TKDE::Fill works with empty tkde #14740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing the TKDE when updating the data with Fill.
I agree the SetKernel() is needed in the InitFromNewData function, since by adding the data both the fixed bandwidth and the adaptive one needs to be re-computed.
A possible optimisation would be to have a function UpdateKernel
, which will re-use the existing kernel, but just changing the fixed bandwidth or the adaptive one, depending on the case.
@phsft-bot build |
Starting build on |
Build failed on ROOT-ubuntu2004/python3. |
Build failed on ROOT-ubuntu2204/nortcxxmod. Failing tests: |
Build failed on windows10/default. Failing tests: |
hist/hist/src/TKDE.cxx
Outdated
@@ -1015,8 +1023,7 @@ Double_t TKDE::TKernel::operator()(Double_t x) const { | |||
Bool_t useCount = (fKDE->fBinCount.size() == n); | |||
// also in case of unbinned unweighted data fSumOfCounts is sum of events in range | |||
// events outside range should be used to normalize the TKDE ?? | |||
Double_t nSum = fKDE->fSumOfCounts; //(useBins) ? fKDE->fSumOfCounts : fKDE->fNEvents; | |||
//if (!useCount) nSum = fKDE->fNEvents; | |||
Double_t nSum = (useCount) ? fKDE->fSumOfCounts : fKDE->fNEvents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is causing a test to fail. The normalisation of the TKDE is wrong, because now nSum is (in case of unbinned, useCount=false) computed from all events, instead it should be computed from all the events in the range (see SetBinCounts).
This line has to be reverted as before.
We could add a warning (or error) , maybe better in SetKernel
so it is not for every event when fKDE->fSumOfCounts is zero, so we avoid having inf
values
Build failed on ROOT-performance-centos8-multicore/soversion. Failing tests: |
Build failed on mac12arm/cxx20. Failing tests: |
Test Results 18 files 18 suites 4d 8h 6m 48s ⏱️ For more details on these failures, see this check. Results for commit cf18add. ♻️ This comment has been updated with latest results. |
as suggested by lmoneta. This was causing a test to fail. The normalisation of the TKDE was wrong, because now nSum was (in case of unbinned, useCount=false) computed from all events, instead it should be computed from all the events in the range (see SetBinCounts).
as suggested by lmoneta
Fixes #7808
This is happening because in when the parentheses operator overload
TKDE::operator()(Double_t x)
calls ReInit(const_cast<TKDE*>(this))->ReInit()
it returns before setting the fKernel in the case of new data.One approach is to call SetKernel here:
or call it at the end of InitFromNewData().
When that happens, the fKernel is no longer null but this error is reproducible with both iterative options -
With Adaptive we get NaN and Fixed we get inf
This is because the weight calculation is using the nSum that is 0 when binning is not used
Inversing that gives the infinity in the Iteration:Fixed case
This fix:
nullptr
)Results:
Gives
0.487581