如何更改向量的比例?

时间:2018-07-23 13:32:01

标签: algorithm scale data-processing

我有一个向量A,我们可以缩放到(1,10)吗?

A = [0.06968048677109477,      0.07091805084676589,      0.07506590429005261,      0.09044325046970765,      0.0908465379725413,      0.10471009623683523,      0.10539538950750547,      0.1056711444959778,      0.1058978683826518,      0.1060517166406799,      0.10666426409947774,      0.106760038969985,      0.10684882498871025,      0.10708945255736063,      0.10720561359279776      0.12979174345223443,      0.13562228877496077,      0.13563624887480935,      0.13597957216781367,      0.13622839687165716,      0.1364550028417469,      0.13711208167062497,      0.13781207673985127,      0.1382417752997873,      0.13829000163905658,      0.14263838186789873,      0.14366697585135071,      0.1445867019056321,      0.1495675689904077,      0.15003042280326156,      0.16038058859231508,      0.1606127314494579,      0.16244828451643853,      0.16370120071381172,      0.1639400518074859]

1 个答案:

答案 0 :(得分:0)

获取A中的最小值和最大值。

比例因子将是:

factor = (10.0 - 1.0) / (max - min);

对于v中的每个值A,您将通过缩放函数进行转换:

v = 1.0 + ((v - min) * factor)