[Dart-dev] [6829] DART/trunk/DART_LAB/matlab/kurt.m: updated version based on input from tim and jeff.

nancy at ucar.edu nancy at ucar.edu
Wed Feb 26 14:33:07 MST 2014


Revision: 6829
Author:   nancy
Date:     2014-02-26 14:33:07 -0700 (Wed, 26 Feb 2014)
Log Message:
-----------
updated version based on input from tim and jeff.

Modified Paths:
--------------
    DART/trunk/DART_LAB/matlab/kurt.m

-------------- next part --------------
Modified: DART/trunk/DART_LAB/matlab/kurt.m
===================================================================
--- DART/trunk/DART_LAB/matlab/kurt.m	2014-02-26 21:25:34 UTC (rev 6828)
+++ DART/trunk/DART_LAB/matlab/kurt.m	2014-02-26 21:33:07 UTC (rev 6829)
@@ -10,23 +10,17 @@
 %
 % DART $Id$
 
-% compute mean  - WARNING: this assumes the array is laid out
-% so the number of items is the second dimension, e.g. [1, 4]
-
-nvals = size(vals, 2);
-m = sum(vals) / nvals;
-
-% compute s2 and s4 
-del = vals - m;
-s2 = sum(del .* del);                % element-by-element *
-s4 = sum(del .* del .* del .* del);  % ditto
+% count of items; array of diffs from mean
+nvals = numel(vals);
+del = vals - mean(vals);
     
-% compute m2 and m4 
-m2 = s2 / nvals;
-m4 = s4 / nvals;
+% compute the square and 4th power of the diffs from mean
+m2 = mean(del .^ 2);
+m4 = mean(del .^ 4);
 
-% finally, the kurtosis value.  this is the version of kurtosis
-% that does NOT subtract 3.0 from the result.
-k = (m4 ./ (m2 .* m2));
+% compute the kurtosis value.  this is the version 
+% of the kurtosis formula that is not nonbiased and
+% does not subtract 3.0 from the result.
+k = (m4 ./ (m2 .^ 2));
 
 end 


More information about the Dart-dev mailing list