Page 1 of 1

How to get the median of each row of a matrix

Posted: Wed May 27, 2015 2:53 pm
by zcmcgurk
So I guess this is similar question to one posted previously. I was wondering how you can get the median value for each row in a matrix. So here is some of the code I am using but I keep on getting this error "## SX22. Expected Type REAL, Got VECTOR[REAL] Instead >>>>(forecastA,i),0.5)<<<<"

Code: Select all

ewise medforecast(i)=%fractiles(%xrow(forecastA,i),0.5)

Re: How to get the median of each row of a matrix

Posted: Wed May 27, 2015 8:04 pm
by TomDoan
%fractiles returns a VECTOR (since it can take a VECTOR of desired quantiles). So you have to reference the 1st element---note the (1) at the end.

ewise medforecast(i)=%fractiles(%xrow(forecastA,i),0.5)(1)