Re: Strange behaviour of <=?



"Mattias " <mattias_winterdahl@xxxxxxxxxxxx> wrote in message <gvllkl$mic$1@xxxxxxxxxxxxxxxxxx>...
"us " <us@xxxxxxxxxxxxxxx> wrote in message <gvlk22$6q8$1@xxxxxxxxxxxxxxxxxx>...
"Mattias " <mattias_winterdahl@xxxxxxxxxxxx> wrote in message <gvljmq$a4s$1@xxxxxxxxxxxxxxxxxx>...
Hi everyone! I have a problem I hope someone could help me with.

I have a vector from which I want to store the values below some percentile. So I tried both quantile() and prctile() like this:

quant_q = quantile(Q, quantile_lim);

while i <= length(Q)
if Q(i) <= quant_q
base_q(j) = Q(i);
...

The strange thing is that I only get values like 0.7000, 0.8000, 0.3000 though I know I have values that are below my quantile limit with another "decimal form", e.g. 0.7422. Why do I only get decimal values that end in zeros? Does anyone know why I get this strange behaviour? I would very much appreciate any help on this!

/MW

can you produce a copy/paste-able example of typical SMALL data set and a complete loop...

us

Data set:
Q = [0.9111 0.9778 0.7222 0.7000 0.8000 0.7833 1.003 1.022 0.9556 0.9333 0.9000];

i = 1;
j = 1;
quantile_lim = 0.25;
quant_q = quantile(Q, quantile_lim);
while i <= length(Q)
if Q(i) <= quant_q
base_q(j) = Q(i);
j = j + 1;
end
i = i + 1;
end

I tried this myself, but then it works. Is it my original Q-vector that could be the source of this error? And in that case how? The data has passed quite some steps up till here. I imported it from an excel-file, checked for any NaNs, removed those etc.

a slighly different approach could look like this

d=[
0.9111 0.9778 0.7222 0.7000 0.8000,...
0.7833 1.003 1.022 0.9556 0.9333 0.9000
];
qlim=.25;
lim=quantile(d, qlim);
[ix,ix]=histc(d,[0,lim,1]);
r=d(find(ix==1))
% r = 0.7222 0.7 0.7833

us
.



Relevant Pages

  • Re: Strange behaviour of <=?
    ... I have a vector from which I want to store the values below some percentile. ... So I tried both quantile() and prctile() like this: ... can you produce a copy/paste-able example of typical SMALL data set and a complete loop... ...
    (comp.soft-sys.matlab)
  • Re: Mathematicas Quantile[] vs. Matlabs prctile()
    ... I've been calculating the 5th percentile of some data in Mathematica using ... the Quantile[] function. ... The help text for the PRCTILE function in MATLAB indicates ... and 87.5th percentile and performs linear interpolation to determine the ...
    (sci.math.symbolic)
  • Re: Strange behaviour of <=?
    ... I have a vector from which I want to store the values below some percentile. ... So I tried both quantile() and prctile() like this: ...
    (comp.soft-sys.matlab)
  • Re: Strange behaviour of <=?
    ... I have a vector from which I want to store the values below some percentile. ... So I tried both quantile() and prctile() like this: ... It was the original data file that was a little bit screwed up. ...
    (comp.soft-sys.matlab)
  • Strange behaviour of <=?
    ... I have a vector from which I want to store the values below some percentile. ... So I tried both quantile() and prctile() like this: ...
    (comp.soft-sys.matlab)