finding an observation that belongs to a range
5 次查看(过去 30 天)
显示 更早的评论
Hi,
A=10455.875;
B=[0.183360563
0.977332866
1.52157357
0.478903256
2.062533507
1.057391671
2.703804872
0.387156764
1.509153916
0.780345876
0.584786482
0.630546822
1.164499219
2.18467966
1.120225382
1.442432903
0.57270282
1.521600334
1.302900886
1.38032646
0.904185496
1.462748054
0.874747668
0.939408895
0.578160289
0.704073418
0.432654455
0.874389253
2.079124229
1.250012066
1.764877112
1.294445292
2.933153035
0.67952879
0.819383367
1.113401832
0.416496245
0.960391501
0.932682761]
I am trying to find to which part of the distribution of B variables A belongs if these parts are segmented by 10% for each segment.
I wrote the following codes: x2=quantile(B,0.1:0.1:1); x3= histc(A,x2);%%%find the segment x4=find(x3==1);
these codes work well if A is above the first 10% segment and below the last 10% segment but I am unable to generate what i want if A is lower than any value in B and A is higher than any value in B (such as in this case, where i want the codes to tell me that A belongs to the last 10% by showing a value of 1 for the last decile in x3). Are there any remedy to this situation?
0 个评论
回答(1 个)
Oleg Komarov
2011-7-6
Use
x2 = quantile(B,0.1:0.1:.9);
x3 = histc(A,[-inf x2 inf])
But you'll have to throw away the last value of x3 (unless A is Inf)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!