<bdo id='EK1HT'></bdo><ul id='EK1HT'></ul>
      <i id='EK1HT'><tr id='EK1HT'><dt id='EK1HT'><q id='EK1HT'><span id='EK1HT'><b id='EK1HT'><form id='EK1HT'><ins id='EK1HT'></ins><ul id='EK1HT'></ul><sub id='EK1HT'></sub></form><legend id='EK1HT'></legend><bdo id='EK1HT'><pre id='EK1HT'><center id='EK1HT'></center></pre></bdo></b><th id='EK1HT'></th></span></q></dt></tr></i><div id='EK1HT'><tfoot id='EK1HT'></tfoot><dl id='EK1HT'><fieldset id='EK1HT'></fieldset></dl></div>

      <small id='EK1HT'></small><noframes id='EK1HT'>

      <tfoot id='EK1HT'></tfoot>

      <legend id='EK1HT'><style id='EK1HT'><dir id='EK1HT'><q id='EK1HT'></q></dir></style></legend>

    1. 如何将正负十进制数列表标准化为特定范围

      How to normalize a list of positive and negative decimal number to a specific range(如何将正负十进制数列表标准化为特定范围)

      • <i id='cgq4a'><tr id='cgq4a'><dt id='cgq4a'><q id='cgq4a'><span id='cgq4a'><b id='cgq4a'><form id='cgq4a'><ins id='cgq4a'></ins><ul id='cgq4a'></ul><sub id='cgq4a'></sub></form><legend id='cgq4a'></legend><bdo id='cgq4a'><pre id='cgq4a'><center id='cgq4a'></center></pre></bdo></b><th id='cgq4a'></th></span></q></dt></tr></i><div id='cgq4a'><tfoot id='cgq4a'></tfoot><dl id='cgq4a'><fieldset id='cgq4a'></fieldset></dl></div>
        • <bdo id='cgq4a'></bdo><ul id='cgq4a'></ul>

              <tbody id='cgq4a'></tbody>

            <small id='cgq4a'></small><noframes id='cgq4a'>

            <legend id='cgq4a'><style id='cgq4a'><dir id='cgq4a'><q id='cgq4a'></q></dir></style></legend>

              1. <tfoot id='cgq4a'></tfoot>
                本文介绍了如何将正负十进制数列表标准化为特定范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个十进制数列表如下:

                I have a list of decimal numbers as follows:

                [-23.5, -12.7, -20.6, -11.3, -9.2, -4.5, 2, 8, 11, 15, 17, 21]
                

                我需要规范化这个列表以适应 [-5,5] 范围.
                我如何在python中做到这一点?

                I need to normalize this list to fit into the range [-5,5].
                How can I do it in python?

                推荐答案

                获取输入范围很简单:

                old_min = min(input)
                old_range = max(input) - old_min
                

                这是棘手的部分.您可以乘以新范围并除以旧范围,但这几乎可以保证顶部存储桶只会得到一个值.您需要扩大输出范围,使顶部存储桶与所有其他存储桶的大小相同.

                Here's the tricky part. You can multiply by the new range and divide by the old range, but that almost guarantees that the top bucket will only get one value in it. You need to expand your output range so that the top bucket is the same size as all the other buckets.

                new_min = -5
                new_range = 5 + 0.9999999999 - new_min
                output = [floor((n - old_min) / old_range * new_range + new_min) for n in input]
                

                这篇关于如何将正负十进制数列表标准化为特定范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)
                <i id='595Hz'><tr id='595Hz'><dt id='595Hz'><q id='595Hz'><span id='595Hz'><b id='595Hz'><form id='595Hz'><ins id='595Hz'></ins><ul id='595Hz'></ul><sub id='595Hz'></sub></form><legend id='595Hz'></legend><bdo id='595Hz'><pre id='595Hz'><center id='595Hz'></center></pre></bdo></b><th id='595Hz'></th></span></q></dt></tr></i><div id='595Hz'><tfoot id='595Hz'></tfoot><dl id='595Hz'><fieldset id='595Hz'></fieldset></dl></div>
                  <tbody id='595Hz'></tbody>
                <tfoot id='595Hz'></tfoot>

                      1. <legend id='595Hz'><style id='595Hz'><dir id='595Hz'><q id='595Hz'></q></dir></style></legend>
                        • <bdo id='595Hz'></bdo><ul id='595Hz'></ul>
                        • <small id='595Hz'></small><noframes id='595Hz'>