将(-inf ... + inf)到(0 ... 1)范围内的任何值标准化.是否可以? [英] Normalize any value in range (-inf...+inf) to (0...1). Is it possible?

查看:112
本文介绍了将(-inf ... + inf)到(0 ... 1)范围内的任何值标准化.是否可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们具有max..min值的具体范围,则很容易将其标准化为0..1浮点值,但是如果我们没有具体的限制?是否可以构建通用函数以使其输出介于 0 和 1 之间?我认为这是不可能的,但我不是数学专家.

If we have concrete range of max..min value it is quite easy to normalize it to 0..1 float values, but if we don't have concrete limits? Is it possible to build universal function to have output between 0 and 1? In my mind I think it is impossible but I am not math expert.

我正在搜索JavaScript或PHP的实现,但是C/C ++/Python/Delphi上的任何代码都可以提供示例(如果有的话)

I'm searching for implementation on JavaScript or PHP, but any code on C/C++/Python/Delphi is OK to provide examples ( if there are some )

推荐答案

有很多方法可以做到这一点.我将省略 -inf + inf 的映射,这可以通过条件语句来完成.

There are many ways to do this. I'll leave out mapping -inf and +inf, which can be done with conditional statements.

  1. exp(x)/(1 + exp(x))或等效的 1//(1 + exp(-x))其中 exp 是指数函数.这是一个物流功能.
  2. atan(x)/pi + 1/2
  3. (tanh(x)+1)/2
  4. (1 + x/sqrt(1 + x * x))/2
  5. (1 + x/(1 + abs(x))/2
  6. (erf(x)+1)/2
  1. exp(x) / (1 + exp(x)) or the equivalent 1 / (1 + exp(-x)) where exp is the exponential function. This is a logistic function.
  2. atan(x) / pi + 1 / 2
  3. (tanh(x) + 1) / 2
  4. (1 + x / sqrt(1 + x*x)) / 2
  5. (1 + x / (1 + abs(x)) / 2
  6. (erf(x) + 1) / 2

您可能已经注意到,其中大多数都映射到(-1,1)并将其更改为(0,1).前者通常比较容易.这是这些功能的图形:

You have probably noticed that most of these take a mapping to (-1, 1) and change it to (0, 1). The former is usually easier. Here is a graph of these functions:

在我的Python 3.5.2中,最快的是(1 + x/(1 + abs(x))* 0.5 .

In my Python 3.5.2, the fastest was (1 + x / (1 + abs(x)) * 0.5.

这篇关于将(-inf ... + inf)到(0 ... 1)范围内的任何值标准化.是否可以?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆