可以使用Numpy's Linspace获得指定间隔内的等距数字:
$ import numpy as np
$ np.linspace(0,10,5)
>>> array([ 0. , 2.5, 5. , 7.5, 10. ])
不过,我想在间隔的开始和结束时取样更多的数字。例如,如果我的间隔是[0-10]
,我需要5个样本。一个好的例子是:
>>> array([0, 1, 5, 9, 10])
我知道有人可能会说有很多方法可以对这个空间进行采样,例如:[0, 0.5, 5, 9.5, 10]
是另一个很好的示例。我不介意它是如何采样的,我只对采样方法感兴趣,这种方法在样本空间的开始和结束时返回更多的样本。你知道吗
一种解决方案是从高斯分布中抽取指数样本,如果你得到一个接近分布平均值的数字,你就可以在样本空间的起点或终点附近抽取一个数字。然而,这种方法似乎比它需要的更复杂,而且你不能保证得到好的样本。你知道吗
有人知道在样本空间的开始和结束处生成样本的好方法吗?你知道吗
您可以重新缩放
tanh
以获得具有可调整块度的序列:这将给您提供更多的样本到间隔的结尾:
你可以选择一个更高的指数来得到更频繁的间隔。你知道吗
要在间隔的开始和结束处获得更多样本,请将原始邻域空间对称为0,然后将其移动。你知道吗
一般功能:
示例:
相关问题 更多 >
编程相关推荐