Bug 121566 - rms scalar is wrong
Summary: rms scalar is wrong
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-08 01:10 UTC by Enzo Pascale
Modified: 2006-02-08 05:50 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enzo Pascale 2006-02-08 01:10:52 UTC
Version:           1.2.0_svn_489756 (using KDE 3.3.2,  (3.1))
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-13)
OS:                Linux (i686) release 2.6.8-2-686-smp

in
void KstVector::updateScalars()

it is

_scalars["sigma"]->setValue(sumsq = sqrt((_scalars["sumsquared"]->value() - sum * sum / double(_nsum)) / double(_nsum-1)));
_scalars["rms"]->setValue(sqrt(sumsq/double(_nsum)));


it should be
_scalars["rms"]->setValue(sqrt(_scalars["sumsquared"]->value()/double(_nsum)));
Comment 1 George Staikos 2006-02-08 05:33:38 UTC
SVN commit 506997 by staikos:

correct RMS
Looks like a refactoring gone wrong...  Ok for 1.2.0 and trunk?
CCBUG: 121566


 M  +2 -2      kstvector.cpp  


--- branches/kst/hfi_calib/kst/kst/kstvector.cpp #506996:506997
@@ -195,9 +195,9 @@
 
     if (_nsum >= 2) {
       double sum = _scalars["sum"]->value();
-      double sumsq;
+      double sumsq = _scalars["sumsquared"]->value();
       _scalars["mean"]->setValue(_mean = sum/double(_nsum));
-      _scalars["sigma"]->setValue(sumsq = sqrt((_scalars["sumsquared"]->value() - sum * sum / double(_nsum)) / double(_nsum-1)));
+      _scalars["sigma"]->setValue(sqrt((sumsq - sum * sum / double(_nsum)) / double(_nsum-1)));
       _scalars["rms"]->setValue(sqrt(sumsq/double(_nsum)));
     } else {
       _scalars["sigma"]->setValue(_max - _min);
Comment 2 Netterfield 2006-02-08 05:37:03 UTC
Yes.
cbn

On February 7, 2006 08:33 pm, George Staikos wrote:
[bugs.kde.org quoted mail]
Comment 3 Matthew Truch 2006-02-08 05:40:40 UTC
> correct RMS
> Looks like a refactoring gone wrong...  Ok for 1.2.0 and trunk?
> CCBUG: 121566


I don't know if I'm in the "reviewer's list", but looks good to me.  
Comment 4 George Staikos 2006-02-08 05:50:17 UTC
SVN commit 506998 by staikos:

fix RMS computation
BUG: 121566


 M  +2 -2      kstvector.cpp  


--- trunk/extragear/graphics/kst/kst/kstvector.cpp #506997:506998
@@ -195,9 +195,9 @@
 
     if (_nsum >= 2) {
       double sum = _scalars["sum"]->value();
-      double sumsq;
+      double sumsq = _scalars["sumsquared"]->value();
       _scalars["mean"]->setValue(_mean = sum/double(_nsum));
-      _scalars["sigma"]->setValue(sumsq = sqrt((_scalars["sumsquared"]->value() - sum * sum / double(_nsum)) / double(_nsum-1)));
+      _scalars["sigma"]->setValue(sqrt((sumsq - sum * sum / double(_nsum)) / double(_nsum-1)));
       _scalars["rms"]->setValue(sqrt(sumsq/double(_nsum)));
     } else {
       _scalars["sigma"]->setValue(_max - _min);