scipy.stats.qmc.LatinHypercube.

integers#

LatinHypercube.integers(l_bounds, *, u_bounds=None, n=1, endpoint=False, workers=1)[source]#

l_bounds (包含) 到 u_bounds (不包含) 中抽取 n 个整数,或者如果 endpoint=True,则从 l_bounds (包含) 到 u_bounds (包含) 中抽取。

参数:
l_boundsint 或 类数组的 int

要抽取的最低(带符号)整数(除非 u_bounds=None,在这种情况下,此参数为 0,并且此值用于 u_bounds)。

u_boundsint 或 类数组的 int,可选

如果提供,则为要抽取的最大(带符号)整数之上的一个(有关 u_bounds=None 时的行为,请参见上文)。 如果是类数组,则必须包含整数值。

nint,可选

在参数空间中生成的样本数。 默认为 1。

endpointbool,可选

如果为 true,则从区间 [l_bounds, u_bounds] 中采样,而不是默认的 [l_bounds, u_bounds)。 默认为 False。

workersint,可选

用于并行处理的 worker 数量。 如果给出 -1,则使用所有 CPU 线程。 仅在使用 Halton 时才支持。 默认为 1。

返回值:
sample类数组 (n, d)

QMC 样本。

注释

可以安全地将与 MC 相同的 [0, 1) 到整数的映射与 QMC 一起使用。 您仍然可以获得无偏性、强大的大数定律、渐近无限的方差减少和有限的样本方差界限。

要将样本从 \([0, 1)\) 转换为 \([a, b), b>a\),其中 \(a\) 是下限,\(b\) 是上限,则使用以下转换

\[\text{floor}((b - a) \cdot \text{sample} + a)\]