相关疑难解决方法(0)

检测未知来源的时间段

如何检测无限序列中的重复数字?我试过Floyd&Brent检测算法,但什么都没有......我有一个生成器,产生0到9(含)的数字,我必须认识到它的一个时期.

示例测试用例:

import itertools

# of course this is a fake one just to offer an example
def source():
    return itertools.cycle((1, 0, 1, 4, 8, 2, 1, 3, 3, 1))

>>> gen = source()
>>> period(gen)
(1, 0, 1, 4, 8, 2, 1, 3, 3, 1)
Run Code Online (Sandbox Code Playgroud)

python algorithm math floyd-cycle-finding

7
推荐指数
1
解决办法
4844
查看次数

查找算法信号中的周期性

在测试关于以下递归关系的猜想

在此输入图像描述 ,

为数字序列声称某种类型的周期性,我写了一个python程序,它计算序列并将它们打印在一个表中.

 1   # Consider the recursive relation x_{i+1} = p-1 - (p*i-1 mod x_i)
 2   # with p prime and x_0 = 1. What is the shortest period of the
 3   # sequence?
 4   
 5   from __future__ import print_function
 6   import numpy as np
 7   from matplotlib import pyplot  as plt
 8   
 9   # The length of the sequences.
 10  seq_length = 100
 11  
 12  upperbound_primes = 30
 13  
 14  # Computing a list of prime numbers up …
Run Code Online (Sandbox Code Playgroud)

python signal-processing periodic-task

7
推荐指数
1
解决办法
4612
查看次数