[英]RMS minimization speed-up
[Environment: MATLAB 64 bit, Windows 7, Intel I5-2320] [环境:MATLAB 64位,Windows 7,Intel I5-2320]
I would like to RMS-fit a function to experimental data y
, so I am minimizing the following function (by using fminsearch
): 我想RMS-拟合实验数据的函数y
,所以我最小化以下函数(通过使用fminsearch
):
minfunc = rms(y - fitfunc)
From the general point of view, does it make sense to minimize: 从一般的角度来看,最小化是否有意义:
minfunc = sum((y - fitfunc) .^ 2)
instead and then (after minimization) just do minfunc = sqrt(minfunc / N)
to get the fit RMS error? 相反,然后(在最小化之后)只需要minfunc = sqrt(minfunc / N)
来获得合适的RMS误差?
To reformulate the question, how much time (roughly, in percent) would fminsearch
save by not doing sqrt
and 1/(N - 1)
each time? 要重新fminsearch
这个问题, fminsearch
不执行sqrt
和1/(N - 1)
会节省多少时间(大约百分比)? I wouldn't like to decrease readability of my code if my CPU / MATLAB are so fast that it wouldn't improve performance by at least a percent. 如果我的CPU / MATLAB速度如此之快以至于无法将性能提高至少一个百分点,我就不会降低代码的可读性。
Update: I've tried simple tests, but the results are not clear: depending on the actual value of the minfunc
, fminsearch
takes more or less time. 更新:我已经尝试了简单的测试,但是结果不清楚:根据minfunc
的实际值, minfunc
fminsearch
会花费一些时间。
The general answer for performance questions: 性能问题的一般答案:
If you just want to figure out what is faster, design a benchmark and run it a few times. 如果您只是想找出更快的方法,请设计一个基准并运行几次。
By just providing general information it is not likely that you will determine which method is 1 percent faster. 仅提供一般信息,就不可能确定哪种方法快1%。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.