Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Matlab - RMS-value
Replies: 2   Last Post: Oct 11, 2012 11:16 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Richard Crozier

Posts: 111
Registered: 3/19/09
Re: Matlab - RMS-value
Posted: Oct 11, 2012 11:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Tom Lane" <tlane@mathworks.com> wrote in message <k56js0$he1$1@newscl01ah.mathworks.com>...
> > RMS1 = sqrt( mean(inVec)^2 + var(inVec) );
> > RMS2 = sqrt( 1/length(inVec) * sum(inVec.^2) );

> ...
> > Why is there a difference ? Round-off error or something else ?
>
> You're right, something else. Ordinarily var uses 1/(n-1) rather than 1/n in
> estimating the variance of a sample of size n. You can supply a flag to get
> it to use 1/n, and then the results match:
>

> >> v = 1:10;
> >> sqrt(mean(v)^2 + var(v))

> ans =
> 6.2783

> >> sqrt(1/length(v) * sum(v.^2))
> ans =
> 6.2048

> >> sqrt(mean(v)^2 + var(v,1))
> ans =
> 6.2048
>
> -- Tom


There's also:

>> rmsval = norm(1:10) / sqrt(length(1:10))

rmsval =

6.2048e+000



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.