我如何正确地将非常大的数字算法盟友归一化为相对较小的数字范围? [英] How do I properly normalize very large numbers algorithmic ally to a relatively small range of numbers?

查看:66
本文介绍了我如何正确地将非常大的数字算法盟友归一化为相对较小的数字范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据从 Excel 导入的自定义用户数据找到一种方法来调整音调.

I'm trying to find a way to adjust the pitch of tones based on custom user data imported from excel.

self.changePitch(30 + (parseInt(self.infoCollection.collection[j].array[i])-200/(3600)));

以上代码适用于最多约 5,000 的正常值".但是,我想将它们归一化以始终介于最小和最大频率之间.(200 和 3800)

The above code works for "normal values" up to about 5,000. However, I want to normalize them to always fall between a minimum and maximum frequency. (200 and 3800)

我尝试使用此处找到的公式:https://stats.stackexchange.com/questions/70801/how-to-normalize-data-to-0-1-range其中说使用 (x-minval)/(maxval-minval)但是,这并不适用于所有情况.使用非常大的数字时.IE 5000万还是会超过最大频率.

I've tried using the equation found here: https://stats.stackexchange.com/questions/70801/how-to-normalize-data-to-0-1-range Which says to use (x-minval)/(maxval-minval) However, this doesn't work for all cases. When using very large numbers. IE 50 million it will still exceed the maximum frequency.

我试图找到一种方法,将任何有理数归一化到数亿.

I'm trying to find a way that this will normalize any rational number up to the hundreds of millions.

抱歉造成混乱.我正在制作一个应用程序,它根据放置在图表上的数据播放声音.目的是让有视觉障碍的用户更好地理解数据,使用声音来获取彼此相关的值.我的问题是人类无法听到高于某个数字的频率,因此如果值高于 5000 左右,应用将不会播放该数字的任何声音.

Sorry for the confusion. I'm making an app that plays sound based on data placed on a graph. The purpose is to allow users with visual impairments to better understand the data using sound to get values that are relative to each other. My problem is that humans can't hear frequencies above a certain number so if there are values above 5000 or so, the app won't play any sound for that number.

示例:A 公司的利润为 200 美元,B 公司的利润为 5000 万美元.用户会听到 A 公司的声音,但 B 公司听不到,因为频率超出了人类的听觉范围.

Example: Profits from company A were $200 and company B were $50 million. The users would hear a sound for company A, but not company B because the frequency would be out of human hearing range.

推荐答案

下面的函数将执行线性归一化(感谢 SMcCrohan) 并且您可以将您需要的值传递给它.

The function below will perform linear normalization (thanks S McCrohan) and you can pass it the values you'll need.

https://jsfiddle.net/7cn57wnd/

function normalize(enteredValue, minEntry, maxEntry, normalizedMin, normalizedMax) {

    var mx = (enteredValue-minEntry)/(maxEntry-minEntry);
    var preshiftNormalized = mx*(normalizedMax-normalizedMin);
    var shiftedNormalized = preshiftNormalized + normalizedMin;

    return shiftedNormalized;

}

//Acceptable values: 0 - 10,000,000
//User enters: 99,000,000
//Normalization window: 200 - 3800

normalize(99000000, 0, 100000000, 200, 3800);

//Returns 3764

这篇关于我如何正确地将非常大的数字算法盟友归一化为相对较小的数字范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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