[SciPy-User] circular statistic, anybody?
Travis Oliphant
oliphant@enthought....
Sun Oct 16 10:25:28 CDT 2011
The functions are fairly straightforward implementations of the concepts discussed here:
http://en.wikipedia.org/wiki/Directional_statistics
The range [low,high] is assumed to be periodic and linearly mapable to [0, 2*pi]. These numbers are then interpreted as angles, converted to complex numbers on the unit circle and the standard mean of the complex number computed.
The angle of this mean-value complex number is the returned mean (mapped back to the range [low, high])
The magnitude of this mean-value complex number is used to calculate the variance (scaled by the mapping coefficient).
More tests and a link to the wiki-pedia article would be useful in the documentation.
I am not familiar with the CircStats package in R but it looks to have nice specialization to particular domains where circular statistics are relevant (time periods, and angles).
Thanks,
-Travis
On Oct 12, 2011, at 7:28 PM, josef.pktd@gmail.com wrote:
> Some of the few functions in scipy.stats where I have no idea what
> they are doing (and whether they are doing the correct thing) are the
> circular statistics, circmean, circvar and circstd. (And they are one
> of the few ones where I have no interest in figuring it out.)
>
> Test coverage is zero, and they are a bit picky on inputs
> http://projects.scipy.org/scipy/ticket/1537
>
> I would like to get some verified results, and improved docstrings
> wouldn't hurt either.
>
> I found package circular in R
>
>>>> from scipy import stats
>>>> x = np.arange(20)/20.*np.pi
>>>> stats.circmean(x)
> 1.4922565104551515
>
> in R:
>
>> library(circular)
>> xc = 0:19
>> xc = xc /20 * pi
>> mean(circular(xc))
> Circular Data:
> Type = angles
> Units = radians
> Template = none
> Modulo = asis
> Zero = 0
> Rotation = counter
> [1] 1.492256510455152
>
> That's the only case I managed to match. If xc is in [0, 2*pi], then R
> circular produces different results (NaN or a different number with
> argument modulo=2pi for example)
>
>> From the R help:
> """
> The function circular is used to create circular objects. as.circular
> and is.circular coerce an object to a circular and test whether an
> object is a circular data.
> Usage
>
> circular(x, type = c("angles", "directions"),
> units = c("radians", "degrees", "hours"),
> template = c("none", "geographics", "clock12", "clock24"), modulo =
> c("asis", "2pi", "pi"),
> zero = 0, rotation = c("counter", "clock"), names)
> """
>
> Does anybody have an idea what these options mean (I don't), and what
> the scipy.stats.circ* functions are actually doing?
>
> Thanks,
>
> Josef
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
---
Travis Oliphant
Enthought, Inc.
oliphant@enthought.com
1-512-536-1057
http://www.enthought.com
More information about the SciPy-User
mailing list