我需要对一组数字进行自相关,据我所知,它只是集合与自身的相关性.
我已经尝试使用numpy的相关函数,但我不相信结果,因为它几乎总是给出一个向量,其中第一个数字不是最大的,因为它应该是.
所以,这个问题实际上是两个问题:
numpy.correlate做什么?在测试关于以下递归关系的猜想
,
为数字序列声称某种类型的周期性,我写了一个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) 我的问题不是特定于语言的……我可能会用C#或Python来实现,除非语言的特定功能可以帮助我获得所需的信息。
有没有人知道的某种算法可以帮助我确定数字列表是否包含重复模式?
假设我有几个数字清单...
[12, 4, 5, 7, 1, 2]
[1, 2, 3, 1, 2, 3, 1, 2, 3]
[1, 1, 1, 1, 1, 1]
[ 1, 2, 4, 12, 13, 1, 2, 4, 12, 13]
Run Code Online (Sandbox Code Playgroud)
我需要检测每个列表中是否有重复的模式...例如,列表1返回false,但是列表2、3和4返回true。
我在想也许要对列表中出现的每个值进行计数,如果val 1 == val 2 == val n ...那就可以了。还有更好的主意吗?