Skip to content

Add doctests and refactor Monte Carlo estimation functions - #12703

Open
akiels wants to merge 2 commits into
TheAlgorithms:masterfrom
akiels:add-doctests-maths-monte-carlo
Open

Add doctests and refactor Monte Carlo estimation functions #12703
akiels wants to merge 2 commits into
TheAlgorithms:masterfrom
akiels:add-doctests-maths-monte-carlo

Conversation

@akiels

@akiels akiels commented May 1, 2025

Copy link
Copy Markdown

Contributes to #9943

This pull request refactors and improves the implementation of the Monte Carlo estimation functions:

  • Refactors functions to return values instead of printing, improving testability.
  • Adds missing type hints.
  • Renames function function_to_integrate to the more descriptive semicircle_function.
  • Clarifies docstrings.
  • Adds doctests for each function:
    • pi_estimator
    • area_under_curve_estimator
    • area_under_line_estimator_check
    • pi_estimator_using_area_under_curve

All doctests pass using python3 -m doctest -v path/to/file.py

akiels added 2 commits May 1, 2025 10:19
- Refactored all functions to return values instead of printing output.

- Added doctests for each fucntion.

- Clarified docstrings.

- Improved code style (typing hints, naming) to align with repo conventions.
Removed __main__ block not used fot script execution.
@alex2998668174

alex2998668174 commented May 2, 2025 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants