scipy.stats.qmc.scale

scipy.stats.qmc.scale(sample, l_bounds, u_bounds, *, reverse=False)[源代码]

从单位超立方体到不同边界的采样缩放。

要从以下位置转换样本,请执行以下操作 \([0, 1)\)\([a, b), b>a\) ,具有 \(a\) 下限和 \(b\) 上界。使用以下转换:

\[(b-a)\cdot\text{示例}+a\]
参数
samplearray_like(n,d)

按比例取样。

l_bounds, u_boundsarray_like(d,)

下界和上界(分别为 \(a\)\(b\) )。如果 reverse 为True,表示要转换到单位超立方体的原始数据范围。

reverse布尔值,可选

反转从不同边界到单位超立方体的变换。默认值为False。

退货
samplearray_like(n,d)

缩放样本。

示例

将单位超立方体中的3个采样变换为边界:

>>> from scipy.stats import qmc
>>> l_bounds = [-2, 0]
>>> u_bounds = [6, 5]
>>> sample = [[0.5 , 0.75],
...           [0.5 , 0.5],
...           [0.75, 0.25]]
>>> sample_scaled = qmc.scale(sample, l_bounds, u_bounds)
>>> sample_scaled
array([[2.  , 3.75],
       [2.  , 2.5 ],
       [4.  , 1.25]])

并转换回单位超立方体:

>>> sample_ = qmc.scale(sample_scaled, l_bounds, u_bounds, reverse=True)
>>> sample_
array([[0.5 , 0.75],
       [0.5 , 0.5 ],
       [0.75, 0.25]])