-
Notifications
You must be signed in to change notification settings - Fork 4
feat: dynamic integrator selection #40
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: main
Are you sure you want to change the base?
Conversation
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.
Also tests for cdf, pdf, logpdf, and Mellin g estimation should be rewritten with new integrators
|
||
"""Base class for integral calculation""" | ||
|
||
def compute_integral(self, func: Callable, params: dict) -> IntegrationResult: |
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.
params should be in class constructor and rename to compute
Returns: moment approximation and error tolerance | ||
""" | ||
|
||
full_output_requested = params.pop('full_output', False) |
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.
By default, it called "verbose" parameter
|
||
|
||
class RQMCIntegrator: | ||
|
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.
Duplicate RQMC docs here
src/mixtures/nm_mixture.py
Outdated
@@ -59,156 +60,175 @@ def _params_validation(self, data_collector: Any, params: dict[str, float | rv_c | |||
raise ValueError("Gamma cant be zero") | |||
return data_class | |||
|
|||
def _classical_moment(self, n: int, params: dict) -> tuple[float, float]: | |||
def _classical_moment(self, n: int, params: dict, integrator: Integrator = None) -> tuple[float, float]: |
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.
Its should better to be
def _classical_moment(self, n: int, integrator: Integrator = DefaultIntegrator(default params))
src/mixtures/nm_mixture.py
Outdated
|
||
Returns: moment approximation and error tolerance | ||
|
||
""" | ||
mixture_moment = 0 | ||
error_tolerance = 0 | ||
integrator = integrator or QuadIntegrator() |
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.
With previous remark this line is useless
src/mixtures/nm_mixture.py
Outdated
rqmc = integrator.compute_integral(func=lambda u: norm.cdf((x - self.params.distribution.ppf(u)) / np.abs(self.params.sigma)), **params) | ||
return rqmc.value, rqmc.error |
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.
better to call it result, or integration_result
19a9ca1
to
93da7ae
Compare
93da7ae
to
51a7303
Compare
Implement dynamic integrator selection and enabling the use of custom integrators