(In reply to Kash Shampur [:kshampur] ⌚EST from comment #3) > Just learned it also exists in the standard lib https://docs.python.org/3.8/library/statistics.html#statistics.geometric_mean > only for python >= 3.8. Checking CI it seems all our machines are on >=3.9. > before osx 10.15 was on 3.7 and looks like it is on 3.11 now, after the upgrade from relops. > win/linux are 3.9.x so it will be fine as well (and are slated to be upgraded to 3.11 eventually fwiw) > > so maybe using the standard lib over scipy might be better To verify this a bit further, I tried generating several non zero random arrays of varying length and compared scipy vs stdlib implementations, because I was concerrnced of this comment [here](https://docs.python.org/3/library/statistics.html#statistics.geometric_mean): `No special efforts are made to achieve exact results. (However, this may change in the future.)` I found that they are pretty much the same, and differences that might occur are within numerical tolerance of `1e-17` to `1e-16` so we can treat both implementations as being equivalent
Bug 1893066 Comment 4 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
(In reply to Kash Shampur [:kshampur] ⌚EST from comment #3) > Just learned it also exists in the standard lib https://docs.python.org/3.8/library/statistics.html#statistics.geometric_mean > only for python >= 3.8. Checking CI it seems all our machines are on >=3.9. > before osx 10.15 was on 3.7 and looks like it is on 3.11 now, after the upgrade from relops. > win/linux are 3.9.x so it will be fine as well (and are slated to be upgraded to 3.11 eventually fwiw) > > so maybe using the standard lib over scipy might be better To verify this a bit further, I tried generating several non zero random arrays of varying length and compared scipy vs stdlib implementations, because I was concerned of this comment [here](https://docs.python.org/3/library/statistics.html#statistics.geometric_mean): `No special efforts are made to achieve exact results. (However, this may change in the future.)` I found that they are pretty much the same, and differences that might occur are within numerical tolerance of `1e-17` to `1e-16` so we can treat both implementations as being equivalent
(In reply to Kash Shampur [:kshampur] ⌚EST from comment #3) > Just learned it also exists in the standard lib https://docs.python.org/3.8/library/statistics.html#statistics.geometric_mean > only for python >= 3.8. Checking CI it seems all our machines are on >=3.9. > before osx 10.15 was on 3.7 and looks like it is on 3.11 now, after the upgrade from relops. > win/linux are 3.9.x so it will be fine as well (and are slated to be upgraded to 3.11 eventually fwiw) > > so maybe using the standard lib over scipy might be better To verify this a bit further, I tried generating several non zero random arrays of varying length and compared scipy vs stdlib implementations, because I was concerned of this comment [here](https://docs.python.org/3/library/statistics.html#statistics.geometric_mean): `No special efforts are made to achieve exact results. (However, this may change in the future.)` I found that they are pretty much the same, and differences that might occur are within numerical tolerance of `1e-17` to `1e-16` so we can treat both implementations as being equivalent **edit** forgot to add/check for completeness, the tolerance does depend on the order of magnitude of the elements of the array. The `1e-17` to `1e-16` tolerance was for an array with elements between (0,1). If I increase the range to be between (0,10-1000) the tolerances adjust accordingly as well, up to to `1e-13` on the 1000 end. I think this is expected floating point error. Eitherway `numpy.isclose()` is happy with this
(In reply to Kash Shampur [:kshampur] ⌚EST from comment #3) > Just learned it also exists in the standard lib https://docs.python.org/3.8/library/statistics.html#statistics.geometric_mean > only for python >= 3.8. Checking CI it seems all our machines are on >=3.9. > before osx 10.15 was on 3.7 and looks like it is on 3.11 now, after the upgrade from relops. > win/linux are 3.9.x so it will be fine as well (and are slated to be upgraded to 3.11 eventually fwiw) > > so maybe using the standard lib over scipy might be better To verify this a bit further, I tried generating several non zero random arrays of varying length and compared scipy vs stdlib implementations, because I was concerned of this comment [here](https://docs.python.org/3/library/statistics.html#statistics.geometric_mean): `No special efforts are made to achieve exact results. (However, this may change in the future.)` I found that they are pretty much the same, and differences that might occur are within numerical tolerance of `1e-17` to `1e-16` so we can treat both implementations as being equivalent **edit** forgot to add/check for completeness, the tolerance does depend on the order of magnitude of the elements of the array. The difference of `1e-17` to `1e-16` was for an array with elements between (0,1). If I increase the range to be between (0,10-1000) the difference adjust accordingly as well, up to to `1e-13` on the 1000 end. Just to clarify this is expected floating point error. Eitherway `numpy.isclose()` is happy with this