enter image description here

I have been unusually confused with finding percentile question.

  1. First question is: So if I want to find the median, for such a case like this, can we use the method of finding median, which is choosing a middle number if there are odd numbers and the mean of the middle two numbers if there are even numbers?

  2. Then I want to find what is the median GPA. n = 345 and I do 345 * 0.5 = 172.5. Then should I choose the GPA variable 172.5 belongs to?

  3. How can I find 10% quantile?

  • 2
    $\begingroup$ I think you are confusing yourself a bit. The median is an order statistic. You might have a multi-modal distribution and the median will still be calculated in the same way it would be in the case of a unimodal (your usual Gaussian bell). For the 10% and any other quantile you want, sort your variables, and take the quantile you care about in the same way you would do for a Gaussian. eg. if you have 345 measurements, sort your measurements. The 173-th point of the sorted vector is your median. $\endgroup$ – usεr11852 Apr 15 '15 at 5:44
  • $\begingroup$ self-study? if so add the tag, thanks. $\endgroup$ – Xi'an Apr 15 '15 at 10:15
  • $\begingroup$ Could you explain more about the "sort your measurements" part? Here we need to take both "GPA" and "345 cases" into account, don't we? $\endgroup$ – harumomo503 Apr 15 '15 at 12:34
  • 2
    $\begingroup$ Caution here: There are many ways to calculate quantiles. They should usually give similar answers, but it's not guaranteed. See e.g. Rob J. Hyndman and Yanan Fan. 1996. Sample quantiles in statistical packages. American Statistician 50: 361-365. $\endgroup$ – Nick Cox Apr 15 '15 at 14:38
  • $\begingroup$ @Nick Cox: +1 Thank you for pointing this out, I was all too quick to comment so the OP moved along and I failed to point that out. $\endgroup$ – usεr11852 Apr 16 '15 at 0:46

As other users have pointed out there is a number of ways to calculate the quantiles of a sample. I believe that E. Langford's article Quartiles in Elementary Statistics published in Journal of Statistics Education gives a nice overview of different methods; it closely follows the findings of Hyndman & Fan's article Sample Quantiles in Statistical Packages published in The American Statistician. The wikipedia article on quantiles is also pretty good. Both journal articles are relatively straight-forward reads even for undergraduates so do not feel intimidated by them.

Going now to your particular questions:

  1. Yes, you can choose the method you describe. As mentioned the median is an order statistic that can be defined as having equal upward rank and downward rank. In your 345-element sample that is clearly the 173rd point of the sorted sample.

  2. I think you are misinterpreting what the median is and that's why you are asking this. See the definition I gave at point one. In the case of an even-numbered sample the interpolated value between the two mid-points is the natural consequence.

  3. This brings us to the point I raised in the beginning of this post. There are different ways that you can define the the $q$-th quantile. I would recommend to find the one used by your software of choice, document this choice within your work and then simply use that. For large samples the difference will be probably negligible; if a third party is concerned about this choice it will be clear where any changes should be made.

I personally do not care about the quantile function I use. I use the default in package I am using at the time and I let it be. If I needed to choose I will probably go with the Def. 5 from the Hyndman & Fan paper; the one they say it is popular among hydrologists. It appears to have all the (reasonable) properties a quantile estimation should have (as those were picked by H. & F.) and it is easy to compute/visualize: one gets the ECDF, takes the inverse of it (essentially flipping the axial system), and interpolates through the midpoints. Let me stress this is NOT the default in R (it actually the default in MATLAB); it is type=5 in the quantile function, type=7 is R's default. (H. & F. advocate the use of type=8)

And a tiny R-simulation just to showcase the negligible difference in the case of large sample. I will use a bimodal distribution with a sample size almost equal to the one you have:

# Set your seed for reproducibility

# Make 1000 samples of 350 elements each; 
# each sample is a mixture of two Gaussians
X = replicate( c(rnorm(175, mean=-2), rnorm(175, mean=2)), n=1000)

# Get the R default (method=7) quantiles for q=10
q10tp7 =(apply(X, 2, quantile, type=7 , probs= .1)  )
# Get the MATLAB default (method=5)  quantiles for q=10
q10tp5 =(apply(X, 2, quantile, type=5 , probs= .1)  )

# Check their means crudely:
mean(q10tp7) # [1] -2.827594
mean(q10tp5) # [1] -2.835528

# How about a quick Kolmogorov-Smirnov or a Wilcoxon rank sum test?
ks.test(q10tp5, q10tp7)     # p-value =  0.4658
wilcox.test(q10tp5, q10tp7) # p-value =  0.09401

As you see these two methods in the context of a finite and somewhat large sample are not too different. Just document which method you use and move along with your analysis.

| cite | improve this answer | |

for Q1&2:- as n=345 median is on (345+1)/2=173-rd place(as data are discrete)..... so you no need to mean the values.

for Q3:- 10% quantile is on (345+1)*0.1=34.6-th place........here you need to apply weighted mean "$(34^{th} GPA) + 0.6*[(35^{th} GPA)-(34^{th} GPA)]$"

PS:- you can get x%-quantile on 346*x%-th place.

Or by any Another methods

| cite | improve this answer | |
  • 1
    $\begingroup$ This is one of nine different methods to compute data quantiles offered by R--and there are others. Why do you recommend this particular one? $\endgroup$ – whuber Apr 15 '15 at 15:37
  • $\begingroup$ Because I usually use this. $\endgroup$ – Hemant Rupani Apr 15 '15 at 15:38
  • 3
    $\begingroup$ Well, that's an honest reason! Unfortunately, that makes your answer entirely subjective, whereas we look for objectively supported authoritative answers on this site. Surely you could supply a rationale for why you usually use this formula. $\endgroup$ – whuber Apr 15 '15 at 15:40

1.Calculate the CDF. (Or in this case CMF since it is discrete.

2.Find the x value corresponding to the desired y value (or quantile)

The CMF is obtained by cumulatively adding the bars, then dividing by n. enter image description here

| cite | improve this answer | |
  • $\begingroup$ When your procedure in (2) returns a range of values--as it often will--how will you decide on which $x$ value to use? $\endgroup$ – whuber Apr 15 '15 at 15:37
  • $\begingroup$ Midpoint: since it's to illustrate the concept in a self-study context $\endgroup$ – Rik Apr 15 '15 at 22:04
  • $\begingroup$ You maybe want to point out that this is not a CDF but and ECDF. If it was a CDF we would be sorted. :) $\endgroup$ – usεr11852 Apr 16 '15 at 0:40

Your Answer

