# Finding population median and IQR(x)

I have done the following for the median
$$2(x-1) = .50$$
results in $$x = 1.25$$

For the quartiles, I have $$q_{1}$$--> $$2(x-1)=.25$$ which results in $$q_{1} = 1.125$$
for $$q_{3}$$--> $$2(x-1)=.75$$ which results in $$q_{3}=1.375$$ and then subtract them to get $$.25$$ Please correct me if I am wrong! thank you in advance

The median is the number $$m$$ for which $$\int_{x=-\infty}^m f(x) \, dx = \frac{1}{2}.$$ So you need to solve $$\frac{1}{2} = \int_{x=1}^m 2(x-1) \, dx = \left[x^2 - 2x\right]_{x=1}^m = m^2 - 2m - (1-2) = (m-1)^2.$$

For the IQR, you need to solve for the first and third quartiles in a similar fashion: $$q_1$$ satisfies $$\frac{1}{4} = \int_{x=1}^{q_1} f(x) \, dx,$$ and $$q_3$$ satisfies $$\frac{3}{4} = \int_{x=1}^{q_3} f(x) \, dx.$$ Then the IQR is simply $$q_3 - q_1$$.

An approach using a beta distribution. Let $$Y \sim \mathsf{Beta}(2,1).$$ Then $$X = Y+1.$$ Results are the same as in @heropup's Answer (+1).

The quartiles of $$Y$$ are as follows (using R) are $$1/2$$ for the lower quartile, $$\sqrt{2}/2$$ for the median, and $$\sqrt{3}/2$$ for the upper quartile. The IQR is $$(\sqrt{3} - 1)/2.$$ Also, the lower quartile for $$X$$ is $$1.5$$ and the IQR for $$X$$ is the same as for $$Y.$$ [In R, qbeta is the quantile function (inverse CDF) of a beta distribution.]

qbeta(c(1,2,3)/4, 2, 1)
[1] 0.5000000 0.7071068 0.8660254
sqrt(1:3)/2
[1] 0.5000000 0.7071068 0.8660254


Simulation: By simulation of a million realizations of $$X$$ in R, we can get good approximations to the quartiles, accurate to about three significant digits--and a figure for illustration.

set.seed(223)
x = 1 + rbeta(10^6, 2, 1)
median(x);  IQR(x)
[1] 1.706684    # aprx 1.7071
[1] 0.3666178   # aprx 0.8660
summary(x)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
1.001   1.499   1.707   1.666   1.866   2.000

hdr = "Simulated values of 1+BETA(2,1) with Quartiles"
hist(x, prob=T, br=30, col="skyblue2", main=hdr)
curve(dbeta(x-1, 2, 1), add=T, lwd=3, col="orange")
abline(v=quantile(x, c(1:3)/4), col="darkgreen", lwd=2)