Skip to content

docs(base): fix the angle_std formula and the angle_mean and angle_wrap parameter docs - #253

Open
petercorke wants to merge 1 commit into
rai-opensource:masterfrom
petercorke:docs/angle-mean-std-docstrings
Open

petercorke wants to merge 1 commit into
rai-opensource:masterfrom
petercorke:docs/angle-mean-std-docstrings

Conversation

@petercorke

Copy link
Copy Markdown
Collaborator

What is wrong

Documentation only, in spatialmath/base/vectors.py:

function problem fix
angle_std the formula has sin in both components of the mean vector; the code (and the correct formula) is cos and sin corrected, and says what R is
angle_mean the parameter is documented as v, it is theta; the range is written [-\pi, \pi)] with a stray bracket and the result can be exactly \pi theta, range [-\pi, \pi]
angle_wrap the parameter is documented as v, it is theta theta

Added

  • angle_std is the same quantity as scipy.stats.circstd with its default arguments. I checked this on 300 random samples, the largest difference is 2e-16.
  • a note that angle_mean has no defined value when the unit vectors cancel (for example 0 and pi; it returns pi/2 because of rounding error)

No code changes.

Found while checking, not changed here

angle_std can return nan for a set of identical angles. The mean resultant length R can come out as 1 + 2e-16, so -2 * log(R) is slightly negative and the square root fails with "invalid value encountered in sqrt". For example np.full(100, -2.9). I counted 33 failures in 378 combinations of angle and sample size. I will send that as a separate PR.

…ap parameter docs

- angle_std: the formula had sin in both components of the mean vector, it is
  cos and sin; say what R is, that the result is the same as
  scipy.stats.circstd, and what happens as R tends to zero
- angle_mean: the parameter was documented as v but is theta, and the range
  had a stray bracket; the result is in [-pi, pi]; say that a cancelling set
  of angles has no defined mean
- angle_wrap: the parameter was documented as v but is theta

Documentation only.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants