Repository navigation
Circstats issue3705 - #4472
Circstats issue3705#4472
Conversation
|
Thank for another pull request. Some of these functions are already in scipy and I do not think we want to duplicate the work here unless we make the functions specifically useful for astronomy/astropy. So I think the inclusion of these statistics does require some thoughtful discussion. One option would be that you should submit this pull request to scipy, which would make available to the large community and probably a good idea, as scipy already as a circstats module. However, a useful thing though would be making sure the stat functions work with |
|
Also, are you considering implementing more of the circularly functionality from R? |
|
Thanks @crawfordsm for commenting. In fact, the I will definitely see what is necessary to the functions so that they work properly with Yes. Do you have any circular statistics functionality in mind? |
|
Just some nitpicking:
|
There was a problem hiding this comment.
I don't see where this reference is referenced.
There was a problem hiding this comment.
@pllim Thanks, replaced the asserts by ValueError. Also, it seems that all functions in the stats package have their documentation within docstring.
There was a problem hiding this comment.
@mirca, yes, you are right. In this case, the doc you have is consistent with the package. Never mind. :)
|
@astronomeralex, @eteq, and @mhvk -- I'm curious about your thoughts about inclusion of the code: pros: It is code useful for pulsar astronomy as mentioned in #3705 and has several functions that are not currently available elsewhere. cons: some functionality overlaps with scipy.stats and it is more generally statistical methods rather than astronomy specific. |
|
@crawfordsm @eteq @mhvk That's a good question. I would lean towards including the code for your pro's listed above. This, and other pull requests, keep pressing this issue of whether stats are astro-specific. It seems prudent that we solve this question for the whole module instead of pull by pull. |
|
@crawfordsm - I agree with you: these routines are useful outside of astronomy as well and the aim should be to have them in scipy. The main objection I can see is that for some it would be useful to have them available now rather than wait for things to have moved to a stable release in scipy. For that, we could have our versions in a In the process, we would hopefully also resolve any issues with scipy not being compatible with @mirca - is this something you are willing to pursue? At some level, you'd be our guinea pig, to see how such PRs fare. p.s. For the same reasons as described above, I do think it would be good to eventually move |
There was a problem hiding this comment.
Not that this isn't a useful reference as-is. I was able to Google for it, and find it helpful. But is there not a reference for this that is less ephemeral than some lecture notes, which have a habit of disappearing?
Basically, if there are magic numbers appearing in some code, those numbers have been be well-substantiated in the code itself, or at least reference an easy to find book or something, because otherwise the code is at high risk of becoming a black box. Maybe I'm over-thinking it in this case though. I don't know how common this derivation is.
There was a problem hiding this comment.
@mhvk How this adaptation would look like? You mean using the input data as Quantity objects? Like this:
>>> theta = np.random.uniform(np.pi,-np.pi,10)*u.rad
>>> theta
<Quantity [ 2.68618134,-0.48446623,-2.0186408 , 0.36504648, 2.40310825,
2.75246314, 2.49128996,-1.24308146, 3.12765606, 1.51981347] rad>
>>> circmean(theta)
<Quantity 2.723982080179903 rad>
?
|
@mirca - yes, one would like to be sure the code works with |
|
OK, I did what I should have done before commenting too much. First, I tried and the Given the above and given that the code they use is relatively trivial and even easier to write using That said, I do think any code in astropy should fully use Just to show how the code might look like if full Quantity-aware Alternatively, one could wrap the |
|
@mirca Once you have updated the code to work with Quantities, I'll give it a final review before merging. Although it looks like you will need to rebase most likely due to updates to the change log. |
|
Hi @crawfordsm, @mhvk. I've made some modifications and now the functions are able to handle both |
|
@mirca - had only the most cursory of looks so far, and liked very much that for most of the code there is, as I would have hoped, absolutely no difference between what is done for The exceptions are the degree to radian conversions; my sense would be to not allow this. Effectively, this is equivalent to allowing some special units to be attached to |
|
@crawfordsm, @mhvk, Does this look better? (: I made some modifications in such a way that all functions now will return |
|
@mirca I will try to review it this week and give you comments. |
|
@crawfordsm any thoughts? |
|
|
||
| Returns | ||
| ------- | ||
| circmean : Quantity |
There was a problem hiding this comment.
If an numpy.ndarray, it returns a numpy.ndarray not a quanity which is okay, but this docstring needs to be updated
|
Thanks for all the updates @mirca. A final note is that the docstrings need to be made consistent with how the functions work. I've left an example for |
|
@crawfordsm Nice catch! Do I need to rebase? |
|
Looks like it |
|
@crawfordsm done! :) |
|
Thanks @mirca ! |
Hi,
Some circular statistical functions were implemented, as requested in issue #3705.
These functions are primarily based on those implemented in the R package
CircStats. Therefore, in most of the tests, results are compared with those obtained through similar functions presented in the aforementioned package.Additionally, a function to compute the Cramér-Rao Lower Bounds for the von Mises distribution (which basically gives the uncertainties on estimating the parameters) was implemented. For this function, unfortunately, I could not find examples elsewhere in order to write a reliable enough test. Nonetheless, since the math envolved is simple and it only relies on the maximum likelihood estimation (which has been tested), I think this function is good.
I would be grateful for any comments.