octave-maintainers
[Top][All Lists]
Advanced

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

Ensuring class of output == class of input in statistical functions


From: Rik
Subject: Ensuring class of output == class of input in statistical functions
Date: Mon, 02 May 2011 19:39:15 -0700

5/2/11

The current statistical functions usually start with an isnumeric() test to
weed out bad inputs.  However, Matlab seems to be a bit more forgiving and
accepts numeric and logical arrays.  I'd like to widen the input set to
include logical arrays.  This isn't a problem as there are some defined
rules that Thorsten Meyer tested about which classes get promoted to
double.  Basically, everything except the single class is promoted to double.

However, while looking at this project I noticed that there are several
examples in our statistical functions where the class of the input is not
preserved.  This seems wrong and I'm hoping someone with access to the
Matlab statistics toolbox can verify my thinking.  What is the result of
the following code snippets?

class (poisspdf (single(0), 2))
class (poisspdf (0, single(2)))
class (poisspdf (single(0), single(2)))

My guess is 'single' in every case, although the answer is 'double' in
every case for Octave.

--Rik


reply via email to

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