# Circular Statistics in Python Help

I'm trying to perform some circular statistics in Python and, having never done circular statistics before and being mostly self taught in python, thought I'd turn to this place for some help because I've hit a brick wall. Never posted here before, so if you need more info or if my question doesn't make sense, let me know. I have some dataframe on number of planula (offspring) produced by a group of corals over 3 lunar cycles. A lunar cycle lasts 29 days. I'm trying to find out what the mean lunar day of planula release is for each of the three lunar cycles. I've found the documentation for scipy.stats.circmean, but its relatively unhelpful with determining exactly what input should go where. I've included an image of what part of the dataframe I'm working with looks like for reference. The column lunar is the lunar day, C1:C10 are the 10 corals in my sample, and the Total is the total number of planula produced daily, which is what I'm interested in finding the mean lunar day of. Any and all help would be greatly appreciated.

• You can compute this also manually. Convert the days to x,y coordinates on a clock with 29 instead of 12 figures. Add together the x,y for each birth on a particular day. Compute the angle of the resulting vector to see in which direction/day of the clock it points. That is the average. Mar 20 at 9:46
• 'for each of the three lunar cycles' this is a bit unclear. Are you trying to compute three different averages? But then, the circularity might need to be omitted. Mar 20 at 9:49

## 1 Answer

It looks to me like you want to take the (circular) mean of the Lunar column, weighted by the Total column. But first you need to convert Lunar to radians by multiplying by 2*np.pi/29.

Multiply the radian Lunar by Total (elementwise). Pass that array into circmean then divide by the total Total to get the mean radial Lunar day. Get back to the linear day by reversing the radian conversion.