我需要类似的东西,而不是问here,但更反过来:
给出一个数字列表(上面问题的例子):[1,6,9,100,102,105,109,134,139]我不想说最大差距(在这个例子中是10),但我想说多少组
例如。 3组:1、6、9/100、102、105、109/134、139 2组:1、6、9/100、102、105、109、134、139 ...
这应该是相对的,因为我的数字非常非常不同: [0.1、0.2、1、4、100、110]=>; 3组应引出0.1、0.2/1、4/100、110
尽管0.2和1在绝对值上比1和5更接近(0.8对3),但相对而言,0.2离1(5倍)比离0.1(2倍)更远
我希望能弄清楚我想实现什么
输出示例:
如果数字列表不是巨大的,我会首先计算一个数字和它的前例之间的每一个比率,然后选择最大的分割
例如:
但是请注意这对
numbers_list
的假设:它必须是一个排序的严格正的数字列表,否则这个函数将不起作用一些例子:
相关问题 更多 >
编程相关推荐