From: Edward on
I have some code wherein I use "median(X)" repeatedly, where X is a 2-D array. For some reason, in one instance, instead of outputting a vector, I get a single value.

When debugging, the command runs properly in the command window.

I'm running 7.7.0.471 (R208b) on Red Hat Enterprise Linux 5.5 on an Intel 64-bit quad core.
From: dpb on
Edward wrote:
> I have some code wherein I use "median(X)" repeatedly, where X is a 2-D
> array. For some reason, in one instance, instead of outputting a
> vector, I get a single value.
>
> When debugging, the command runs properly in the command window.
>
> I'm running 7.7.0.471 (R208b) on Red Hat Enterprise Linux 5.5 on an
> Intel 64-bit quad core.

That's a crystal ball question as posed; have to see the code (and
perhaps the data) to do anything other than speculate.

It's either the data isn't what you think it is or the repeated
application of the function twice to an array followed by a vector
reduces it to the single value or somesuch behavior.

--
From: Tom Lane on
>> I have some code wherein I use "median(X)" repeatedly, where X is a 2-D
>> array. For some reason, in one instance, instead of outputting a vector,
>> I get a single value.
>>
>> When debugging, the command runs properly in the command window.
>>
>> I'm running 7.7.0.471 (R208b) on Red Hat Enterprise Linux 5.5 on an Intel
>> 64-bit quad core.
>
> That's a crystal ball question as posed; have to see the code (and perhaps
> the data) to do anything other than speculate.
>
> It's either the data isn't what you think it is or the repeated
> application of the function twice to an array followed by a vector reduces
> it to the single value or somesuch behavior.

Or if the number of rows varies, and it can be equal to one sometimes, then
the median operates along the single row as a vector. In this case it's
helpful to specify that you want to take the median down columns.

-- Tom