# Using the Median to Estimate a Parameter

I am trying to use the Median to estimate the value for the parameter $$a$$ in the following PMF.

$$$$\label{eq1:givenpdf} \mathbb{P}\left[X=\frac{a}{n}\right] = \frac{36}{5}\frac{n^2}{\left(n+1\right)\left(n+2\right)\left(n+3\right)\left(n+4\right)}\ for\ n=1,2,\dots$$$$

When equating the CDF to 0.5 to obtain a formula for the median, the following was obtained: $$$$\label{eq:Median} \implies \frac{a(5a^2+9an+4n^2)}{5(a+2n)(a+3n)(a+4n)} = 0.5$$$$ Solving for $$n$$ yielded: $$n = -0.3389a - (0.1687 \pm 0.2923i)a + (0.0590 \mp 0.1023i)a \approx (-0.5667 \pm 0.1900i)a$$ $$\text{and}$$ $$n= 0.0056 \left[-61a + 60.7433a + 21.2534a \right] \approx 0.1167a$$

For which I chose the real root, for obvious reasons.

How can I use this information to obtain an Estimator for $$a$$ using the median and apply it on the data set attached below (with is summary statistics)?

I tried researching online, however I am still getting confused because the median for the data set provided is $$0.5$$

• What do those columns in the black table mean? Why do you want to use the median to estimate a? Why is a median of 0.5 confusing you? Commented Jun 16, 2022 at 9:09
• I have to construct an estimator for $a$ and I thought to do that using the Method of Quartiles, specifically the Median. I looked online as to how to do it and cannot understand the procedure. Then, I have to use the same estimator for the Sample of 100 readings (that in the black box) to obtain an estimate for $a$ of that sample. Commented Jun 16, 2022 at 9:14
• If the use of the Median to obtain an estimator for $a$ cannot be applied here, I am open to trying other methods of estimation, however, I already used the Method of Moments (which gave a unbiased estimator) and the Sample Maximum (biased estimator) as these are what I am familiar with. Any guidance and help towards finding another estimator (not necessarily using the Median) is appreciated, and if possible some steps to explain the method. Commented Jun 16, 2022 at 9:18
• If the sample size is large (say 100 independent random samples from that distribution), then the maximum $X$ provides usually the exact value of $a$. That's because with a large sample size the maximum $X$ value is very likely to be $a/1=a$.
– JimB
Commented Jun 23, 2022 at 5:31
• @AustinM You are very close to getting the answer on your own. Rather than solving for $n$, you should be solving for $a$, which gives $a \approx \frac{n}{0.1167}$ where $n$ is the median. This would give you that an estimate for $a$ is about $9$ times the median (which corresponds to the correct answer by @MattF). You made things a bit more complicated than needed for this particular problem, but this approach is good and will work in more general cases. Commented Jun 23, 2022 at 18:54

The median of this distribution is at $$a/9$$, since $$P[X<\frac{a}9]=48.6\%$$ $$P[X=\frac{a}9]=\ \ 3.4\%$$ $$P[X>\frac{a}9]=48.0\%$$ So you can estimate $$a$$ as $$9$$ times the median.

(I've deleted my previous answer as it was a bit sloppy.)

Because in a comment you've mentioned the desire for other estimators, here is an implementation of a maximum likelihood estimator. Note that this is not so straightforward because potential estimates of $$a$$ must result in $$a/x$$ (for any observed value of $$X=x$$) being a positive integer.

In short for large sample sizes the maximum likelihood estimator will be the maximum of the observed values. For not-so-large sample sizes the maximum likelihood estimate can be found in the following manner. Here I've used Mathematica but something similar can be produced in R.) The example below generates data for $$a=7.5$$.

(* Generate a random sample of size 5 *)
p = Table[(36/5) n^2/((n + 1) (n + 2) (n + 3) (n + 4)), {n, 1, 10000}];
SeedRandom[12345];
nn = RandomChoice[p -> Range[1, 10000], 5]
x = 7.5/nn;  (* Here a = 7.5 *)

(* Find value for a that maximizes the log of the likelihood and
results in (essentially) all integer values of a/x *)
maxLogL = -Infinity;
mlea =.;
Do[ahat = Max[x]*n; (* Potential estimate of a *)
ss = (ahat/x - Round[ahat/x])^2 // Total;  (* Distance that ahat/x is from all integers *)
(* Only attempt to update ahat if ahat/x consists of integers *)
If[ss < 0.01,
logL = Total[
Log[36/5] + 2 Log[ahat] + 2 Log[#] - Log[ahat + #] -
Log[ahat + 2 #] - Log[ahat + 3 #] - Log[ahat + 4 #] & /@ x];
If[logL > maxLogL, mlea = ahat; maxLogL = logL]
], {n, 1, 25}]

mlea
(* 7.5 *)

mlea/x  (* Check on mlea/x consists of all integers *)
(* {2, 5, 28, 7, 4} *)


Simulations result even for a sample size of 5 in a much, much better estimator than using 9 times the median.

SeedRandom[12345];
nSimulations = 10000;
mle = ConstantArray[0, nSimulations];
medianEstimator = ConstantArray[0, nSimulations];

Do[
(* Generate a random sample of size 5 *)
p = Table[(36/5) n^2/((n + 1) (n + 2) (n + 3) (n + 4)), {n, 1,
10000}];
nn = RandomChoice[p -> Range[1, 10000], 5];
x = 7.5/nn;

(* Median estimator *)
medianEstimator[[i]] = 9 Median[x];

(* Find value for a that maximizes the log of the likelihood and
results in (essentially) all integer values of a/x *)
maxLogL = -Infinity;
mlea =.;
Do[ahat = Max[x]*n; (* Potential estimate of a *)
ss = (ahat/x - Round[ahat/x])^2 // Total;  (* Distance that ahat/
x is from all integers *)
(* Only attempt to update ahat if ahat/x consists of integers *)
If[ss < 0.01,
logL =
Total[Log[36/5] + 2 Log[ahat] + 2 Log[#] - Log[ahat + #] -
Log[ahat + 2 #] - Log[ahat + 3 #] - Log[ahat + 4 #] & /@ x];
If[logL > maxLogL, mlea = ahat; maxLogL = logL]
], {n, 1, 25}];
mle[[i]] = mlea,
{i, 1, nSimulations}]


Here are the results:

{Mean[mle], StandardDeviation[mle], Median[mle]}
(* {7.37627, 0.697574, 7.5} *)

{Mean[medianEstimator], StandardDeviation[medianEstimator], Median[medianEstimator]}
(* {9.09117, 6.764, 7.5} *)


A plot of the relative frequencies of estimates for both the maximum likelihood and median estimators: