source:
proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/graphics/quantile.m
@
37
Last change on this file since 37 was 37, checked in by , 14 years ago | |
---|---|
File size: 417 bytes |
Rev | Line | |
---|---|---|
[37] | 1 | function b = quantile(x,probs) |
2 | % QUANTILE Quantiles of a data vector. | |
3 | % quantile(x,probs) behaves like the R function of the same name. | |
4 | % | |
5 | % Example: | |
6 | % quantile(3:4,[0.3 0.6]) | |
7 | ||
8 | x = sort(x); | |
9 | x = x(:)'; % workaround matlab indexing bug | |
10 | pos = probs*(length(x)-1) + 1; | |
11 | pos_lower = floor(pos); | |
12 | pos_upper = ceil(pos); | |
13 | pos_frac = pos - pos_lower; | |
14 | b = x(pos_lower).*(1-pos_frac) + x(pos_upper).*pos_frac; |
Note: See TracBrowser
for help on using the repository browser.