# Are the first and third quartiles exactly equal to the median of the lower and upper halves of the data?

Suppose I have a set of quantitative data $$x_i$$, with $$1 \le i \le N$$. This set has a median $$M = x_m$$, where the median $$M=x_m$$ where $$m=\frac{N+1}{2}$$ if $$N$$ is odd, or $$M=\frac{x_\mu + x_{\mu+1}}{2}$$, where $$\mu \equiv \frac{N}{2}$$ if $$N$$ is even.

From a conceptual perspective, the first quartile ($$Q_1$$) is the median of the lower half of the data and the third quartile ($$Q_3$$) is the median of the upper half of the data.

Another way of thinking of the quartiles is in terms of percentiles. In this picture $$Q_1$$ and $$Q_3$$ equal the 25th percentile ($$P_{25}$$) and 75th percentile ($$P_{75}$$), respectively.

My intuition tells me that these pictures are equivalent for some values of $$N$$ (e.g. N=7), but because of the way $$M$$ is defined for even $$N$$, they might not be the same in all circumstances.

Under what circumstances are these pictures identical or not identical?