<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157034</link>
    <title>MATLAB Central Newsreader - Which ML function for variance?</title>
    <description>Feed for thread: Which ML function for variance?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 02 Oct 2007 15:04:16 -0400</pubDate>
      <title>Which ML function for variance?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157034#394794</link>
      <author>G.A.M. </author>
      <description>I have two vectors. The element-by-element differences&lt;br&gt;
represent an error quantity. I want to obtain the variance&lt;br&gt;
(or square root) of these two vectors and I don't see a ML&lt;br&gt;
function that will do this.&lt;br&gt;
&lt;br&gt;
Here's what I'm doing right now:&lt;br&gt;
&lt;br&gt;
differences = v1(ndx-rng:ndx+rng) - v2(ndx-rng:ndx+rng);&lt;br&gt;
squaredDiffs = differences.^2;&lt;br&gt;
sumSquares = sum(squaredDiffs);&lt;br&gt;
result = sqrt (sumSquares / (length(squaredDiffs)-1) );&lt;br&gt;
&lt;br&gt;
Is there a more efficient way to do this? Is there a single&lt;br&gt;
ML function I can call that would do the same thing? &lt;br&gt;
&lt;br&gt;
Thanks.</description>
    </item>
    <item>
      <pubDate>Tue, 02 Oct 2007 16:22:09 -0400</pubDate>
      <title>Re: Which ML function for variance?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157034#394810</link>
      <author>Adam </author>
      <description>&quot;G.A.M. &quot; &amp;lt;x0zero@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fdtmlg$t1j$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have two vectors. The element-by-element differences&lt;br&gt;
&amp;gt; represent an error quantity. I want to obtain the variance&lt;br&gt;
&amp;gt; (or square root) of these two vectors and I don't see a ML&lt;br&gt;
&amp;gt; function that will do this.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Here's what I'm doing right now:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; differences = v1(ndx-rng:ndx+rng) - v2(ndx-rng:ndx+rng);&lt;br&gt;
&amp;gt; squaredDiffs = differences.^2;&lt;br&gt;
&amp;gt; sumSquares = sum(squaredDiffs);&lt;br&gt;
&amp;gt; result = sqrt (sumSquares / (length(squaredDiffs)-1) );&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is there a more efficient way to do this? Is there a single&lt;br&gt;
&amp;gt; ML function I can call that would do the same thing? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&lt;br&gt;
std(), var()&lt;br&gt;
&lt;br&gt;
you could locate these by opening help (F1) and searching&lt;br&gt;
for variance, or typing &lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; lookfor variance&lt;br&gt;
&lt;br&gt;
~Adam</description>
    </item>
    <item>
      <pubDate>Tue, 02 Oct 2007 17:07:00 -0400</pubDate>
      <title>Re: Which ML function for variance?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157034#394822</link>
      <author>John D'Errico</author>
      <description>&quot;Adam &quot; &amp;lt;not.my.email@mathworks.com&amp;gt; wrote in message &amp;lt;fdtr7h$2q9&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;G.A.M. &quot; &amp;lt;x0zero@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;fdtmlg$t1j$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I have two vectors. The element-by-element differences&lt;br&gt;
&amp;gt; &amp;gt; represent an error quantity. I want to obtain the variance&lt;br&gt;
&amp;gt; &amp;gt; (or square root) of these two vectors and I don't see a ML&lt;br&gt;
&amp;gt; &amp;gt; function that will do this.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Here's what I'm doing right now:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; differences = v1(ndx-rng:ndx+rng) - v2(ndx-rng:ndx+rng);&lt;br&gt;
&amp;gt; &amp;gt; squaredDiffs = differences.^2;&lt;br&gt;
&amp;gt; &amp;gt; sumSquares = sum(squaredDiffs);&lt;br&gt;
&amp;gt; &amp;gt; result = sqrt (sumSquares / (length(squaredDiffs)-1) );&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Is there a more efficient way to do this? Is there a single&lt;br&gt;
&amp;gt; &amp;gt; ML function I can call that would do the same thing? &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; std(), var()&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; you could locate these by opening help (F1) and searching&lt;br&gt;
&amp;gt; for variance, or typing &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; lookfor variance&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ~Adam&lt;br&gt;
&lt;br&gt;
Actually, no. std and var both subtract off the mean&lt;br&gt;
before squaring. The OP wishes to compute this&lt;br&gt;
without the initial mean subtraction. In one line...&lt;br&gt;
&lt;br&gt;
res = sqrt(sum(differences.^2/(length(differences)-1));&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Wed, 03 Oct 2007 15:16:04 -0400</pubDate>
      <title>Re: Which ML function for variance?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157034#394974</link>
      <author>Peter Perkins</author>
      <description>John D'Errico wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; res = sqrt(sum(differences.^2/(length(differences)-1));&lt;br&gt;
&lt;br&gt;
res = norm(differences)/sqrt(length(differences)-1);&lt;br&gt;
&lt;br&gt;
would also work well.</description>
    </item>
  </channel>
</rss>

