p=[0 100 0 0 0]; % vector of probability mass
cump=cumsum(p); %cumulative probability mass
X=100; %value for which I extract the bin index
Y=discretize(X,cump);cump = 1×5 0 100 100 100 100Y = 4
Hi , in this piece of code , I insert a probability value between 0-100 (0-1 probability) , and by using the discretize function I am checking the index of the bin that this value belongs. The thing is that when this value X is 100 , and the cumulative probability is : [0 100 100 100 100] , I would like the index result to be the 1st bin(or at least the 2nd bin, not the last one.).This cannot happen since each bin includes the left edge, but does not include the right edge, except for the last bin which includes both edges. Is there anyway to fix this problem?
Thanks
Best Answer