我发现这个序列相似马尔钦Ciura的序列:
1, 4, 9, 23, 57, 138, 326, 749, 1695, 3785, 8359, 18298, 39744, etc.
例如,Ciura的顺序是:
1, 4, 10, 23, 57, 132, 301, 701, 1750
这是素数的平均值。 Python代码找到素数的意思是在这里:
import numpy as np
def isprime(n):
''' Check if integer n is a prime '''
n = abs(int(n)) # n is a positive integer
if n < 2: # 0 and 1 are not primes
return False
if n == 2: # 2 is the only even prime number
return True
if not n & 1: # all other even numbers are not primes
return False
# Range starts with 3 and only needs to go up the square root
# of n for all odd numbers
for x in range(3, int(n**0.5)+1, 2):
if n % x == 0:
return False
return True
# To apply a function to a numpy array, one have to vectorize the function
vectorized_isprime = np.vectorize(isprime)
a = np.arange(10000000)
primes = a[vectorized_isprime(a)]
#print(primes)
for i in range(2,20):
print(primes[0:2**i].mean())
输出是:
4.25
9.625
23.8125
57.84375
138.953125
326.1015625
749.04296875
1695.60742188
3785.09082031
8359.52587891
18298.4733887
39744.887085
85764.6216431
184011.130096
392925.738174
835387.635033
1769455.40302
3735498.24225
序列中的差距正在慢慢从2.5到2 也许这个协会降低可以提高希尔排序在将来。
有人挖出了我的序列:-)我在一个数据集上实现了一个排序算法,它的大小非常有限 - 大约是10到50,我发现shellsort是这个范围中最快的一个。我彻底搜索了最好的序列 - 主要发现了Knuths,Sedgewicks等,其中主要基于voodoo和kumba wamba。 Marcin Ciuara似乎是为数不多的基于魔术公式的人,他们实际上做了一些基准测试,并获得了比序列更好的东西,这是我将其发布在OEIS上的主要原因。但我没有给你答案。 – hirschhornsalz 2010-03-29 17:08:05
序列应严格减少,其最后一个元素始终为1.如果gap为1,则表示经典插入排序。所以Ciura的序列正确的是[701,301,132,57,23,10,4,1]。我做了一些测试,壳牌的原始序列对我来说表现更好。 – Jabba 2012-02-28 17:31:26
您提供的链接已损坏。 _“平均壳数最佳增量”_:[abstract](http://www.springerlink.com/content/2akgu9pvc6jl239g/)和[full paper](http://sun.aei.polsl.pl/ 〜mciura/publikacje/shellsort.pdf) – user46874 2012-07-22 23:54:43