Skip to content
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

Check for 0 stddev when generating a random number using normal distribution #615

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Aug 6, 2024

🦟 Bug fix

Fixes gazebosim/gz-sim#2519

Summary

We use std::normal_distribution in our Rand class. From the doc:

The behavior is undefined if stddev is not greater than zero.

So added a check for 0 stddev (sigma) and return mean if its 0.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.98%. Comparing base (11caaf7) to head (59848ab).
Report is 8 commits behind head on gz-math7.

Additional details and impacted files
@@             Coverage Diff              @@
##           gz-math7     #615      +/-   ##
============================================
- Coverage     94.11%   93.98%   -0.14%     
============================================
  Files           146      149       +3     
  Lines          9809     9956     +147     
============================================
+ Hits           9232     9357     +125     
- Misses          577      599      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@azeey azeey added the beta Targeting beta release of upcoming collection label Aug 6, 2024
src/Rand.cc Outdated Show resolved Hide resolved
Signed-off-by: Ian Chen <[email protected]>
@iche033 iche033 merged commit 197e189 into gz-math7 Aug 6, 2024
12 checks passed
@iche033 iche033 deleted the rand_normal branch August 6, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[OdometryPublisher] Crash if initialized with zero gaussian noise standard deviation
2 participants