有没有办法将集合中的整数之和限制为 (0,1) 而无需找到集合中的最大整数?

发布于 2024-11-03 06:02:39 字数 694 浏览 4 评论 0原文

我有一组 n,数字 {N_1, N_2.....N_n}

基本上我想对所有 N_k 的总和做一些事情code> 保持总和的结果在 (0,1) 之间归一化/有界((就像除以某个 f(N_1,N_2..N_n)) 但我不想比较中的所有整数找到最大值的集合,我想保持答案“无量纲”,因此 f 不能是 (N_k)^2 的总和,例如

是否有一个简单的函数 。 f 或其他方法来确保这一点?

编辑 我想要从 (0,infinity)(0,1) 的所有可能总和的映射

f = sum 将不起作用,因为它会始终给出结果 1,因此与总和不成正比。

假设每一项的长度以米为单位...无量纲意味着操作的最终结果不应该有任何单位..例如 2m + 3m/ (2m + 1m) =5/3 没有单位。

然而......有相当明显的答案可能有效,例如f = sum +1或f= sum +2等。这些将随着总和的增加而增长,并且对于总和的大值趋向于1 那么问题可能更加主观,变成可以使用哪种其他类型的 f 以及哪个将为大值提供“最线性”类型的映射?

I have a set of n, numbers {N_1, N_2.....N_n}

Basically I want to do something to the sum of all N_k that keeps the result of the sum normalized/bounded between (0,1) ( (like divide by some f(N_1,N_2..N_n)) but I don't want to compare all integers in the set to find the maximum and I want to keep the answer "dimensionless" so f cannot be the sum of (N_k)^2 for example.

Is there a simple function f or another way to ensure this?

EDIT
I want a mapping of all possible sums from (0,infinity) to (0,1)

f = sum will not work because it will always give a result of 1 and so is not proportional to the sum.

Assuming each term were a length in meters...dimensionless means that the end result of the operation should not have any units..e.g 2m + 3m/ (2m + 1m) =5/3 with no units.

However...there fairly obvious answers that may work e.g. f = sum +1 or f= sum +2 etc. These will grow with the sum and tend to 1 for large values of the sum
the question is then perhaps more subjective and becomes which other kind of f can be used and which will give the "most linear" type of mapping for large values?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

段念尘 2024-11-10 06:02:39

atan(x/k)/(pi/2) 将所有 [0..infinity] 映射到范围 0..1: fooplot

选择一个数字 k,至少是您期望看到的最大数字的一半。输入 k 映射为 0.5。太大的输入将彼此非常接近并且为 1,以致于在舍入中丢失。

atan(x/k)/(pi/2) maps all [0..infinity] to the range 0..1: fooplot

Pick a number k at least half as large as the largest number you expect to see. input k is mapped to 0.5. Too large of inputs will be so close to each other and 1 as to be lost in the roundoff.

满栀 2024-11-10 06:02:39

但我想要一张尽可能线性的地图...最好是比反正切更线性的地图?

我不是数学家,但我的直觉是,从 (0, infinity) 映射到 (0, 1) 的唯一方法是使用函数 f其性质是,当 x 趋于无穷大时,f(x) 渐近于 1。它不可能是线性的。


根据 @Alexandre 的评论,修改后的语句应该是:

  • 一个函数 f,它具有以下属性:f(x) 是常数或渐近于常数,因为 x 趋于无穷大。

  • 这意味着它不能在整个范围内呈线性...除了 f(x) = C 的情况。

但就像我说的……我不是数学家……而他显然是。

but I want a map that is as linear as one can get...preferably something more linear than the inverse tangent?

I'm not a mathematician, but my intuition is that the only way that you map from (0, infinity) to (0, 1) is with a function f that that has the property that f(x) is asymptotic to 1 as x tends to infinity. It cannot be linear.


Per @Alexandre's comment, a revised statement should be:

  • a function f that that has the property that f(x) is either constant or asymptotic to a constant as x tends to infinity.

  • this means that it cannot be linear across the entire range ... except for the case of f(x) = C.

But like I said ... I'm not a mathematician ... and he apparently is.

独自唱情﹋歌 2024-11-10 06:02:39

如果你想要无量纲的东西,你必须采取f 正同质(根据无量纲的定义)。这意味着对于每个 a > 0,

f(a * x_1, ..., a * x_n) = a * f(x_1, ..., x_n).

这确保

sum(a * x_1, ... a * x_n) / f(a * x_1, ..., a * x_n)

不依赖于 a (将与 a 的乘法视为“单位更改”)。换句话说,当您均匀缩放函数 f 的参数时,函数 f 必须线性增长。

齐次函数的基本示例是您提到的:

f(x_1, ..., x_n) = n * max(x_1, ..., x_n)                                     (1)
f(x_1, ..., x_n) = sum(x_1, ..., x_n)                                         (2)

还有欧几里得范数

f(x_1, ..., x_n) = sqrt(n) * sqrt(sum(x_1^2, ..., x_n^2))                     (3)

p-范数,对于p > 1

f(x_1, ..., x_n) = n^(p/(p-1)) * sum(x_1^p, ..., x_n^p) ^ (1/p)               (4)

作为奖励,它们是对称的,这也可能是您的要求之一。选择你想要的。还有其他的,但更复杂。

通过霍尔德不等式得出比率sum / f对于这四个函数来说,总是在 0 和 1 之间(这就是我选择有趣的归一化常数的原因)。请注意,选择 (2) 是一个简单的选择:结果始终为 1。

If you want something dimensionless you must take f positive homogeneous (by definition of dimensionless). This means that for each a > 0,

f(a * x_1, ..., a * x_n) = a * f(x_1, ..., x_n).

This ensures that

sum(a * x_1, ... a * x_n) / f(a * x_1, ..., a * x_n)

does not depend on a (see the multiplication by a as a "change of units"). Put another way, the function f must grow linearly when you scale evenly its arguments.

Basic examples of homogeneous functions are the ones you mentioned:

f(x_1, ..., x_n) = n * max(x_1, ..., x_n)                                     (1)
f(x_1, ..., x_n) = sum(x_1, ..., x_n)                                         (2)

but also the Euclidean norm:

f(x_1, ..., x_n) = sqrt(n) * sqrt(sum(x_1^2, ..., x_n^2))                     (3)

and the p-norms, for p > 1:

f(x_1, ..., x_n) = n^(p/(p-1)) * sum(x_1^p, ..., x_n^p) ^ (1/p)               (4)

As a bonus, they are symmetric, which may also be one of your requirements. Pick whichever you want. There are others, but are more complicated.

By Hölder's inequality the ratio sum / f is always between zero and one for those four functions (this is why I chose the funny normalizing constants). Note that chosing (2) is a trivial choice: the result is always 1.

鹿港巷口少年归 2024-11-10 06:02:39

为什么不直接使用简单的双曲曲线呢?函数y=n/(x+n)将任何正数映射到范围[1,0]。您选择的 n 越高,您的曲线就越平坦。如果取y=1-n/(x+n),它将在[0,1]范围内。因此,n 的选择将表明曲线接近其渐近线的速度。

在这里试试:
http://graph-plotter.cours-de-math.eu/

Why not just use a plain hyperbolic curve? The function y=n/(x+n) maps any positive number to the range [1,0]. The higher you choose n the flatter your curve becomes. If you take y=1-n/(x+n), it will be in the range [0,1]. So the choice of n will indicate how fast your curve will near its assymptote.

Try here:
http://graph-plotter.cours-de-math.eu/

最单纯的乌龟 2024-11-10 06:02:39

我不确定我是否能正确理解这个问题。如果您尝试找到将每个单独元素 N1...Nn 映射到 (0,1) 的映射,您当然可以使用(如您建议的那样)

f( x) = x / max { N1, ..., Nn }

但由于某种原因,您不想取所有元素的最大值。您可以使用

f(x) = x / Σi Ni

但这不一定映射任何元素,甚至接近 1。另一种选择是使用“软最大值”函数,即

f(x) = ex / [eN1 + ... + eN n]

如果值x 不一定是集合中的任何单个元素,而是子集和,那么显然

f(x) = x / Σi Ni

工作得很好,我们现在当 x是你得到的所有元素的总和 1。

但是你说 x 可以趋于无穷大。如果集合 { Ni } 是有限的并且保持不变,这真的会发生吗?

一般来说,如果你想从 (0,∞) 压缩到 (0,1),你不能使用线性函数来做到这一点,原因很明显。对于压缩函数 f : (0,∞) → (0,1) 您需要 d/dx f > 0 且必然 lim x→∞ d/dx f(x) = 0; f(0) = 0; lim x→∞ f(x) = 1。具有这些属性的一些函数是

对于任何正常数 C 为 1 - e-Cx,以及

2 / (1 + e-Cx super>) - 1(S 型函数)。

I'm not sure if I can understand the question right. If you try to find a mapping that maps every individual element N1...Nn to (0,1) you could certainly use (as you propose)

f(x) = x / max { N1, ..., Nn }

but for some reason you don't want to take the maximum of all the elements. You can use

f(x) = x / ∑i Ni

but this doesn't necessarily map any of the elements even near to 1. Another alternative is to use the "soft max" function, i.e.

f(x) = ex / [eN1 + ... + eNn]

If the value of x is not necessarily any individual element of the set but a subset sum, then obviously

f(x) = x / ∑i Ni

works very well, us now when x is the sum of all the elements you get to 1.

But then you say that x can tend to infinity. Can that really happen if the set { Ni } is finite and remains constant?

In general if you want to compress from (0,∞) to (0,1) you can't do that with a linear function for obvious reasons. For a compression function f : (0,∞) → (0,1) you want d/dx f > 0 and necessarily lim x→∞ d/dx f(x) = 0; f(0) = 0; lim x→∞ f(x) = 1. Some functions with these properties are

1 - e-Cx for a any positive constant C, and

2 / (1 + e-Cx) - 1 (the Sigmoid function).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文