从[0.5 - 1]到[0 - 1] [英] Normalizing from [0.5 - 1] to [0 - 1]
问题描述
我被卡在这里,我想这是一个脑筋急转弯。如果我有数字在0.5到1之间的范围,我怎么能规范化它在0到1之间?
感谢任何帮助,也许我只是一点缓慢,因为我一直在过去24小时工作O_O
其他人已经提供了你的公式, 。这里是如何解决这样的问题。
要将 [0.5,1]
映射到 [0,1]
我们将寻找形式 x - > ax + b
。我们将要求将端点映射到端点,并保留该顺序。
方法一:端点映射到端点并保留该订单的要求意味着 0.5
映射到 0
和 1
映射到 1
a *(0.5)+ b = 0(1)
a * 1 + b = 1 2)
这是一个线性方程组的同时系统,可以通过乘以等式<$ c $通过 -2
并将等式(1)
添加到方程式(2)
。这样做,我们得到 b = -1
,并将它代入方程(2)
$ c> a = 2 。因此,映射 x - >方法二:线的斜率通过两点
(x2,y2)
是 (y2-y1)/(x2-x1)。
这里我们将使用(0.5,0)
和(1,1)
以满足端点映射到端点并且映射是顺序保留的要求。因此斜率为
m =(1-0)/(1-0.5)= 1 / 0.5 = $ b
我们有(1,1)
点线上,因此通过线的方程的点斜率形式,我们有
y - 1 = 2 *(x - 1)= 2x - 2
,以便
y = 2x - 1.
我们再次看到 x - > 2x - 1
是一个可以完成这个任务的地图。
I'm kind of stuck here, I guess it's a bit of a brain teaser. If I have numbers in the range between 0.5 to 1 how can I normalize it to be between 0 to 1?
Thanks for any help, maybe I'm just a bit slow since I've been working for the past 24 hours straight O_O
Others have provided you the formula, but not the work. Here's how you approach a problem like this. You might find this far more valuable than just knowning the answer.
To map [0.5, 1]
to [0, 1]
we will seek a linear map of the form x -> ax + b
. We will require that endpoints are mapped to endpoints and that order is preserved.
Method one: The requirement that endpoints are mapped to endpoints and that order is preserved implies that 0.5
is mapped to 0
and 1
is mapped to 1
a * (0.5) + b = 0 (1)
a * 1 + b = 1 (2)
This is a simultaneous system of linear equations and can be solved by multiplying equation (1)
by -2
and adding equation (1)
to equation (2)
. Upon doing this we obtain b = -1
and substituting this back into equation (2)
we obtain that a = 2
. Thus the map x -> 2x - 1
will do the trick.
Method two: The slope of a line passing through two points (x1, y1)
and (x2, y2)
is
(y2 - y1) / (x2 - x1).
Here we will use the points (0.5, 0)
and (1, 1)
to meet the requirement that endpoints are mapped to endpoints and that the map is order-preserving. Therefore the slope is
m = (1 - 0) / (1 - 0.5) = 1 / 0.5 = 2.
We have that (1, 1)
is a point on the line and therefore by the point-slope form of an equation of a line we have that
y - 1 = 2 * (x - 1) = 2x - 2
so that
y = 2x - 1.
Once again we see that x -> 2x - 1
is a map that will do the trick.
这篇关于从[0.5 - 1]到[0 - 1]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!