When will two periodic collectors fire together again?
lcm gives the least common multiple. For positive integer periods starting together, it is the time to their first shared repetition.
numpy.lcm in practice
Collectors firing every six and eight seconds meet again after twenty-four seconds. Clock drift can move physical events away from that ideal schedule.
import numpy as np
np.lcm(6,8)Result 24
中文
两个周期性采集器何时再次同时触发?
lcm 求最小公倍数。在同一起点启动且周期为正整数时,它给出首次共同重复的时间。
numpy.lcm 算例
每 6 秒与每 8 秒采一次的设备在第 24 秒重逢。实际设备有漂移时,这只是理想调度表的结论。
import numpy as np
np.lcm(6,8)结果 24