Calc time pt-circular mean diff?

Given the data set of clock hour times in hours, we can calculate the circular mean and median using the circular library. We can visualise the data and the mean and median with a plot.

However, we want to calculate the difference between each time point and the mean. For example, if the mean is 23 and there are two data points 22 and 1, then the first point is one hour early and the second is two hours past, so -1 and +2. Subtracting each data point from the mean doesn’t seem to produce the desired result, and we don’t know if this is the best way of computing time differences when considering the circular nature of clock time.

To calculate the circular difference between each time point and the mean, you can use the circular library in Python. Here’s how you can do it:

import circular

# Assuming you have a list of clock hour times called 'hours'

# Calculate the circular mean
mean = circular.mean(hours)

# Calculate the circular difference between each time point and the mean
differences = circular.cdiff(hours, mean)

# Print the differences
print(differences)

This will give you the desired result, taking into account the circular nature of clock time.