octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hist with nan's


From: Muhali
Subject: hist with nan's
Date: Wed, 9 May 2012 11:26:26 -0700 (PDT)

For hist (Y, X, NORM), octave normalizes relative to the number of rows in Y.
Since hist understands nan's, it would be more logical so normalize relative
to the non-nan's of Y. The appropriate patch is attached.

M.

--- hist.m      2012-05-09 11:11:55.840231862 -0700
+++ /tmp/hist.m 2012-05-09 11:11:25.924878643 -0700
@@ -149,7 +149,8 @@
   if (nargin > 2 && ! ischar (varargin{iarg}))
     ## Normalise the histogram.
     norm = varargin{iarg++};
-    freq = freq / rows (y) * norm;
+    # freq = freq / rows (y) * norm;
+    freq = freq / sum (!isnan(y)) * norm;
   endif
 
   if (nargout > 0)


--
View this message in context: 
http://octave.1599824.n4.nabble.com/hist-with-nan-s-tp4621323.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]