Question: R quantile function fails at finding deciles of very small values, is there any algorithm that works better than others?

Answer: 
The R quantile function *doesn't* fail at finding deciles of very small values; it's just that the *concept* of deciles becomes ambiguous if you don't have many samples in your set. There are actually 9 different ways to calculate quantiles using the `quantile` function in R, which you can change by setting the `type` parameter.

Here is an example of attempting to extract the deciles of the vector `c(1, 2, 3)`, with each of the 9 methods available. Do any of these meet your expectations? Personally, I like method 7 here, but I guess it really depends on how you define a decile, and for what purposes.

```
sapply(1:9, function(x) quantile(c(1:3), probs = seq(0, 1, 0.1), type = x))
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7]     [,8]  [,9]
#> 0%      1    1    1  1.0  1.0  1.0  1.0 1.000000 1.000
#> 10%     1    1    1  1.0  1.0  1.0  1.2 1.000000 1.000
#> 20%     1    1    1  1.0  1.1  1.0  1.4 1.000000 1.025
#> 30%     1    1    1  1.0  1.4  1.2  1.6 1.333333 1.350
#> 40%     2    2    1  1.2  1.7  1.6  1.8 1.666667 1.675
#> 50%     2    2    2  1.5  2.0  2.0  2.0 2.000000 2.000
#> 60%     2    2    2  1.8  2.3  2.4  2.2 2.333333 2.325
#> 70%     3    3    2  2.1  2.6  2.8  2.4 2.666667 2.650
#> 80%     3    3    2  2.4  2.9  3.0  2.6 3.000000 2.975
#> 90%     3    3    3  2.7  3.0  3.0  2.8 3.000000 3.000
#> 100%    3    3    3  3.0  3.0  3.0  3.0 3.000000 3.000

```
The formal quantile function is not implemented in software R. Otherwise, this software has a mistake. The quantile function is left continuous, for probability p in the interval [0,1]. See Seccion 12 in Parzen, E. (2004) Quantile probability and statistical data modeling. Statistical Science, 19(4), 652-662.

In this sense, if the sample is {1,2,3,4,5,6,7,8,9,10}, the sample quantile are:

1 as 0.1-quantile,

2 as 0.2-quantile,

3 as 0.3-quantile, and so on.

However, the quantile() function in R, type=1, gives:

4 as 0.3-quantile and

8 as 0.7-quantile.

See this example below.

```
> sapply(1:9,function(x) quantile(c(1:10),probs=seq(0,1,0.1),type=x))
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]      [,8]   [,9]
0%      1  1.0    1    1  1.0  1.0  1.0  1.000000  1.000
10%     1  1.5    1    1  1.5  1.1  1.9  1.366667  1.400
20%     2  2.5    2    2  2.5  2.2  2.8  2.400000  2.425
30%     4  4.0    3    3  3.5  3.3  3.7  3.433333  3.450
40%     4  4.5    4    4  4.5  4.4  4.6  4.466667  4.475
50%     5  5.5    5    5  5.5  5.5  5.5  5.500000  5.500
60%     7  7.0    6    6  6.5  6.6  6.4  6.533333  6.525
70%     8  8.0    7    7  7.5  7.7  7.3  7.566667  7.550
80%     8  8.5    8    8  8.5  8.8  8.2  8.600000  8.575
90%     9  9.5    9    9  9.5  9.9  9.1  9.633333  9.600
100%   10 10.0   10   10 10.0 10.0 10.0 10.000000 10.000

```