So its like saying 95% of the items sold in this website costs between $$25 - $150. While some items might cost less than $25 and other items might cost more than $150.

Is there a way to find this? Is this something related to CI - confidence Interval?

  • $\begingroup$ What do you mean by 'the minimum range'? $\endgroup$
    – Macro
    Mar 22, 2012 at 19:24
  • $\begingroup$ See Reference range on Wikipedia. $\endgroup$
    – onestop
    Mar 22, 2012 at 20:08
  • $\begingroup$ What data or related information do you have to begin with? $\endgroup$
    – whuber
    Mar 22, 2012 at 20:14
  • $\begingroup$ Weakly related: stats.stackexchange.com/questions/24588/… $\endgroup$
    – Henry
    Mar 22, 2012 at 21:52
  • 1
    $\begingroup$ This sounds like a homework question. It has to do with standard deviation which is used to calculate confidence intervals. I would say more but in the interest of facilitating your learning I'll direct you to the wikipedia page on standard deviation instead. en.wikipedia.org/wiki/Standard_deviation I'd be happy to discuss this further but please read that, make an attempt at solving the problem, and then ask some intelligent questions and we can go from there. $\endgroup$
    – Will
    Mar 23, 2012 at 2:30

1 Answer 1


If you mean the narrowest range then something like this would do it

dat        <- rnorm(1000000)
ordereddat <- sort(dat)
width      <- ceiling(length(ordereddat) * 0.95)
difdat     <- diff(ordereddat, lag = width)
min        <- which(difdat == min(difdat)) 
c(ordereddat[min[1]] , ordereddat[min[1] + width])


[1] -1.962899  1.961126

If you want as many items above as below then there is the simple but slightly wider

> c(quantile(dat, 0.025),  quantile(dat, 0.975))
     2.5%     97.5% 
-1.960232  1.964565  
  • $\begingroup$ i think c(quantile(dat, 0.025), quantile(dat, 0.975)) fits what i was looking for. thank you $\endgroup$
    – Prabhu M
    Mar 23, 2012 at 4:03

Your Answer

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

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