Repository navigation
Commit 9b83ba0
authored
docs(base): fix the angle_std formula and the angle_mean and angle_wrap parameter docs (#253)
## 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.1 parent 4f81af6 commit 9b83ba0
1 file changed
Lines changed: 31 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
686 | | - | |
| 686 | + | |
687 | 687 | | |
688 | | - | |
| 688 | + | |
689 | 689 | | |
690 | 690 | | |
| 691 | + | |
| 692 | + | |
691 | 693 | | |
692 | 694 | | |
693 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
694 | 708 | | |
695 | 709 | | |
696 | 710 | | |
| |||
708 | 722 | | |
709 | 723 | | |
710 | 724 | | |
711 | | - | |
712 | | - | |
713 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
714 | 728 | | |
715 | 729 | | |
716 | | - | |
| 730 | + | |
| 731 | + | |
717 | 732 | | |
718 | 733 | | |
719 | 734 | | |
720 | | - | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
721 | 742 | | |
722 | 743 | | |
723 | 744 | | |
| |||
730 | 751 | | |
731 | 752 | | |
732 | 753 | | |
733 | | - | |
734 | | - | |
| 754 | + | |
| 755 | + | |
735 | 756 | | |
736 | 757 | | |
737 | 758 | | |
| |||
0 commit comments