Skip to content

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

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

"""
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
plidan123 added a commit that referenced this pull request Jun 25, 2025
feat: dynamic integrator selection
@plidan123 plidan123 mentioned this pull request Jun 26, 2025
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.

3 participants