[Dart-dev] [6788] DART/trunk/DART_LAB/matlab: adding alternate routines for the two matlab functions we use
nancy at ucar.edu
nancy at ucar.edu
Wed Feb 5 10:30:15 MST 2014
Revision: 6788
Author: nancy
Date: 2014-02-05 10:30:15 -0700 (Wed, 05 Feb 2014)
Log Message:
-----------
adding alternate routines for the two matlab functions we use
in the tutorial exercises that require the statistics toolbox.
there need to be corresponding updates in plot_gaussian.m and
oned_model.m to call these instead of kurtosis() and normpdf().
i'll commit new versions of those after i can get a code review.
(i have run them and compared the results to the original
versions and gotten the same answers.)
Added Paths:
-----------
DART/trunk/DART_LAB/matlab/donorm.m
DART/trunk/DART_LAB/matlab/kurt.m
-------------- next part --------------
Added: DART/trunk/DART_LAB/matlab/donorm.m
===================================================================
--- DART/trunk/DART_LAB/matlab/donorm.m (rev 0)
+++ DART/trunk/DART_LAB/matlab/donorm.m 2014-02-05 17:30:15 UTC (rev 6788)
@@ -0,0 +1,26 @@
+function [y] = donorm(x, mu, sigma)
+% computes a gaussian (normal) probabilty distribution function
+% for the points of X with a given mean (mu) and standard deviation (sigma)
+%
+% normal plot, y given x:
+% y = (1 / sigma * sqrt(2*pi)) * e ^^ ((-1/2 * ((x-mu) / sigma)^^2)
+% or
+% g(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{ -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2 }.
+
+%% DART software - Copyright 2004 - 2013 UCAR. This open source software is
+% provided by UCAR, "as is", without charge, subject to all terms of use at
+% http://www.image.ucar.edu/DAReS/DART/DART_download
+%
+% DART $Id$
+
+
+e = 2.71828182845904523536;
+
+basen = (1.0 / (sigma * sqrt(2*pi)));
+expon = -0.50 .* (((x-mu) / sigma).^2 );
+
+y = basen .* (e .^ expon);
+
+end
+
+
Property changes on: DART/trunk/DART_LAB/matlab/donorm.m
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author HeadURL Id
Added: svn:eol-style
+ native
Added: DART/trunk/DART_LAB/matlab/kurt.m
===================================================================
--- DART/trunk/DART_LAB/matlab/kurt.m (rev 0)
+++ DART/trunk/DART_LAB/matlab/kurt.m 2014-02-05 17:30:15 UTC (rev 6788)
@@ -0,0 +1,32 @@
+function k = kurt(vals)
+% computes the kurtosis of the given input array
+%
+% based on the second formula on this web page:
+% http://www.ats.ucla.edu/stat/mult_pkg/faq/general/kurtosis.htm
+
+%% DART software - Copyright 2004 - 2013 UCAR. This open source software is
+% provided by UCAR, "as is", without charge, subject to all terms of use at
+% http://www.image.ucar.edu/DAReS/DART/DART_download
+%
+% 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
+
+% compute m2 and m4
+m2 = s2 / nvals;
+m4 = s4 / nvals;
+
+% finally, the kurtosis value. this is the version of kurtosis
+% that does NOT subtract 3.0 from the result.
+k = (m4 ./ (m2 .* m2));
+
+end
Property changes on: DART/trunk/DART_LAB/matlab/kurt.m
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author HeadURL Id
Added: svn:eol-style
+ native
More information about the Dart-dev
mailing list