1
$\begingroup$

In the distribution below, how would I find the values that lies between 30% and 50% of the distribution? R code would be handy but not essential!

28, 28, 29, 30, 30, 31, 31, 31, 31, 32, 32, 32, 34, 35, 36, 37, 38

$\endgroup$
2
  • $\begingroup$ You need to specify better your question. Is it about probability or frequency? In the later case, a simple question of interpolation in the frequency empirical distribution. If you want inference, like confidence intervals, we need more. $\endgroup$ Jun 22, 2015 at 8:16
  • $\begingroup$ Question edited. Don't need inference/confidence intervala $\endgroup$
    – luciano
    Jun 22, 2015 at 8:22

2 Answers 2

3
$\begingroup$

So you just want the quantiles of the sample! If you do not know what they are, look at wikipedia: https://en.wikipedia.org/?title=Quantile When specified by percent values, quantiles are called percentiles.

Here is some simple R code:

 d <- c(28, 28, 29, 30, 30, 31, 31, 31, 31, 32, 32, 32, 34, 35, 36, 37, 38)
 quantile(d,c(0.3, 0.5))
 30%  50% 
30.8 31.0 
$\endgroup$
2
  • $\begingroup$ thanks, you've answered my question. But regarding terminology, I didn't want to quantiles, did I? The quantiles are 0.3 and 0.5, so I wanted the values at the point of these quantiles (whatever these values are called). $\endgroup$
    – luciano
    Jun 22, 2015 at 10:34
  • 3
    $\begingroup$ luciano quantiles are sample values (order statistics), or sometimes, weighted averages of adjacent order statistics. The median is the 0.5 quantile, $x_{0.5}$. $\endgroup$
    – Glen_b
    Jun 22, 2015 at 11:41
2
$\begingroup$

Since you specifically asked for the elements of the vector meeting your condition:

how would I find the values that lies between 30% and 50% of the distribution

test=c(28,28,29,30,30,31,31,31,31,32,32,32,34,35,36,37,38)
q.30=quantile(test,0.30)
q.50=quantile(test,0.50)
test[(test[]>=q.30)&((test[]<=q.50))]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.