octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #48690] basic statistics functions should retu


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input
Date: Mon, 8 Aug 2016 17:45:15 +0000 (UTC)
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0

Follow-up Comment #13, bug #48690 (project octave):

was going to upload last patch for std([]) = NaN when I saw it was failing the
test:


assert(std (ones (1,3,0,2), ones(1,3,0,2)))
-verbatim

checking matlab 2016a:


>> std(ones(1,3,0,2))
ans =
   Empty array: 1-by-1-by-0-by-2


I went back and checked mean, median, mode, etc., and they behave similarly
with multidimensional empties. I see Matlab documentation about the simple
empty matrix case, but nothing for ndim>2.

I'm assuming the old test was there because of former matlab behavior. Also . 
Matlab behavior gets strange depending on which dimension has 0 elements. For
example:

>> mean(ones(1,2,2,0,2))
ans =
   Empty array: 1-by-1-by-2-by-0-by-2

>> mean(ones(1,0,2,0,2))
ans =
   Empty array: 1-by-1-by-2-by-0-by-2

>> mean(ones(1,0,2,1,2))
ans(:,:,1,1,1) =
   NaN
ans(:,:,2,1,1) =
   NaN
ans(:,:,1,1,2) =
   NaN
ans(:,:,2,1,2) =
   NaN


I'm assuming we're venturing into the land of undocumented Matlab. Ignoring
multidimensional empties I have a the last patch ready to upload now. If I
could ignore that last case it's easy to catch ndims>2 and output a matching
multidimensional empty. The last case is a little wonky, but it wouldn't take
much more to catch that case. Do we want it to?

I'm assuming Matlab 'fixed' the std([])=NaN issue and the rest is
unintentional. Other than function([])=NaN, is there anything documented I
should be sure to follow?  And then how much of the undocumented should I try
to emulate?


I believe there was some recent list traffic on a similar topic of
multidimensional empties and matlab compatibility, but my google fu is failing
me.  

I'll likely copy this over to maintainers-list later to get other opinions if
needed.

Nick J.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48690>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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