Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

Amellgo
Copy link
Collaborator

@Amellgo Amellgo commented May 12, 2025

Implement dynamic integrator selection and enabling the use of custom integrators

@Amellgo Amellgo requested a review from Engelsgeduld May 12, 2025 19:15
Copy link
Collaborator

@Engelsgeduld Engelsgeduld left a 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:
Copy link
Collaborator

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)
Copy link
Collaborator

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:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate RQMC docs here

@@ -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]:
Copy link
Collaborator

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))


Returns: moment approximation and error tolerance

"""
mixture_moment = 0
error_tolerance = 0
integrator = integrator or QuadIntegrator()
Copy link
Collaborator

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

Comment on lines 140 to 141
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
Copy link
Collaborator

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

@Amellgo Amellgo force-pushed the api/abstract-integrator branch from 19a9ca1 to 93da7ae Compare June 1, 2025 20:21
@Amellgo Amellgo force-pushed the api/abstract-integrator branch from 93da7ae to 51a7303 Compare June 2, 2025 21:54
@Amellgo Amellgo requested a review from Engelsgeduld June 2, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants