对归一化数据上的曲线拟合结果进行归一化 [英] Denormalize results of curve fit on normalized data

查看:733
本文介绍了对归一化数据上的曲线拟合结果进行归一化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Matlab 中使用lsqvurcefit拟合指数衰减函数.为此,我首先标准化我的数据,因为它们的数量级不同.但是我不确定如何对我拟合的参数进行非规范化处理.

I am fitting an exponential decay function with lsqvurcefit in Matlab. To do this I first normalize my data because they differ several orders of magnitude. However Im not sure how to denormalize my fitted parameters.

我的拟合模型是s = O + A * exp(-t/T),其中t和s是已知的,t的顺序为10 ^ -3,而s的顺序为10 ^ 5.因此,我从它们的均值中减去它们并除以它们的标准偏差.我的目标是找到在给定的时间t上最接近s的最佳A,O和T.但是我不知道如何对所得的A O和T进行归一化.

My fitting model is s = O + A * exp(-t/T) where t and s are known and t is in the order of 10^-3 and s in the order of 10^5. So I subtract from them their mean and divide them by their standarddeviation. My goal is to find the best A, O and T that at the given times t will result most near s. However I dont know how to denormalize my resulting A O and T.

也许有人知道该怎么做?我只在SO上找到问题,但并没有真正解决相同的问题.

Might somebody know how to do this? I only found this question on SO about normalisation, but does not really address the same problem.

推荐答案

规范化时,必须记录每个特征的均值和标准差.然后,您可以轻松地使用这些值进行反规范化.

When you normalize, you must record the means and standard deviations for each of your featuers. Then you can easily use those values to denormalize.

例如

A = [1 4 7 2 9]';
B = 100 475 989 177 399]';

因此您可以立即将其标准化:

So you could just normalize right away:

An = (A - mean(A)) / std(A)

,但随后您将无法返回到原始A.因此,请首先保存均值和标准差.

but then you can't get back to the original A. So first save the means and stds.

Am = mean(A); Bm = mean(B);
As = std(A);  Bs = std(B);
An = (A - Am)/As;
Bn = (B - Bm)/Bs;

现在执行所需的任何处理,然后进行反规范化:

now do whatever processing you want and then to denormalize:

Ad = An*As + Am;
Bd = Bn*Bs + Bm;

我敢肯定,如果您有很多功能(例如,您必须为每个功能键入代码,这是什么任务!),那将是一个问题,因此,假设您的数据按矩阵data,其中每个样本是一行,每列是一个要素.现在您可以这样做:

I'm sure you can see that that's going to be an issue if you have a lot of features (i.e. you have to type code out for each feature, what a mission!) so lets assume your data is arranged as a matrix, data, where each sample is a row and each column is a feature. Now you can do it like this:

data = [A, B]

means = mean(data);
stds = std(data);

datanorm = bsxfun(@rdivide, bsxfun(@minus, data, means), stds);

%// Do processing on datanorm

datadenorm = bsxfun(@plus, bsxfun(@times, datanorm, stds), means);

使用归一化的tf拟合模型参数(AOT)后,您的模型将期望归一化输入并产生归一化输出.因此,要使用它,您应该先 normalize t,然后 denormalize f.

After you have fit your model parameters (A,O and T) using normalized t and f then your model will expect normalized inputs and produce normalized outputs. So to use it you should first normalize t and then denormalize f.

因此,通过在规范化的新t上运行模型来查找新的f.因此,f(tn)其中tn = (t - tm)/tstm是您的训练(或拟合)t集和ts std的平均值.然后,要获得正确的幅值f,您只需将f规格化即可,因此完整的解决方案是

So to find a new f by running the model on a normalized new t. So f(tn) where tn = (t - tm)/ts and tm is the mean of your training (or fitting) t set and ts the std. Then to get your correct magnitude f you must denormalize only f, so the full solution would be

 f(tn)*fs + fm

再次,您需要做的就是保存您用于标准化的均值和标准差.

So once again, all you need to do is save the mean and std you used to normalize.

这篇关于对归一化数据上的曲线拟合结果进行归一化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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