Skip to content
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

HistogramFactory struggles with samples with various scales #2655

Open
josephmure opened this issue May 13, 2024 · 2 comments
Open

HistogramFactory struggles with samples with various scales #2655

josephmure opened this issue May 13, 2024 · 2 comments
Labels
Milestone

Comments

@josephmure
Copy link
Collaborator

What happened?

When the first part of a sample has very low scale, and the second part a larger scale, issues happen with HistogramFactory::build.

  1. When the sample size is small, build does not return.
  2. When the sample size is large, it produces a std::bad_alloc error.

How to reproduce the issue?

import openturns as ot
sample = ot.Uniform(-1e-10, 1e-10).getSample(100) # use sample size 10 to get the no return problem
sample2 = ot.Uniform(-1, 1).getSample(5)
sample.add(sample2)
hf = ot.HistogramFactory()
hf.build(sample)

Version

master

Operating System

Linux

Installation media

from source

Additional Context

No response

@josephmure josephmure added the bug label May 13, 2024
@josephmure
Copy link
Collaborator Author

Tagging @vchabri who discovered the issue.

@jschueller
Copy link
Member

jschueller commented May 13, 2024

in that case the bandwith computed with the default Freedman and Diaconis bandwith rule, and is small (~1e-10) wrt the range resulting in a huge binNumber (14482017289):

const UnsignedInteger binNumber = static_cast<UnsignedInteger>(ceil((max - min) / bandwidth + 0.5));

else the Scott rule yields something usable ~1e-1, (set useQuantile=False)

not sure what should do here to select Scott in these cases, but sounds important to get into 1.23

@jschueller jschueller added this to the 1.23 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants