Skip to content

Improve numerical stability of sigmoid function - #15769

Open
mehulikhanra904-prog wants to merge 2 commits into
TheAlgorithms:masterfrom
mehulikhanra904-prog:stable-sigmoid
Open

mehulikhanra904-prog wants to merge 2 commits into
TheAlgorithms:masterfrom
mehulikhanra904-prog:stable-sigmoid

Conversation

@mehulikhanra904-prog

Copy link
Copy Markdown

Describe your change

  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?

Changes

  • Implemented numerically stable sigmoid calculations.
  • Used separate formulas for positive and negative inputs to prevent exponential overflow.
  • Added validation for non-numeric inputs.
  • Added validation for NaN and infinite values.
  • Added doctests for normal, extreme, scalar, and invalid inputs.

Checklist

  • I have read the contributing guidelines.
  • This pull request is my own work.
  • I understand that pull requests must pass automated tests.
  • This PR changes only one algorithm file.
  • Function names follow Python naming conventions.
  • Type hints are included.
  • Doctests are included.

No existing issue is being resolved.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Nov 17, 2026
@mehulikhanra904-prog

Copy link
Copy Markdown
Author

check

This branch has not been deployed

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

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant