Join ML Engineer Interview MasterClass (April Cohort) led by FAANG Data Scientists | Just 6 seats remaining...
ML Engineer MasterClass (April) | 6 seats left
Last Updated: March 2024
Given N samples from a uniform distribution [0, d], how would you estimate d?
Note that there are a number of ways the parameter d can be estimated given N samples of data. One such approach is to take the max(x) of samples to estimate the d given that d is the maximum possible value in a uniform range. However, this introduces a bias since max(x) is always less than or equal to d. Therefore, on average, we expect the estimation using max(x) to be less than d.
Therefore, we need a correction that helps us get the unbiased estimation of d. This can be done so in the following manner.
Step 1 – Probability Distribution of X.max
For a uniform distribution of U(0, d), each sample X.i has the probability density function (PDF) given by:

The cumulative distribution function (CDF) of X.i is:
The maximum of N samples, X.max, will be less than or equal to some value x if and only if all N samples are less than or equal to x. Since the samples are independent, the CDF of X.max is the product of the individual CDFs:

Step 2 – Derive the PDF of X.max
Using the CDF of X.max, we can derive the PDF of X.max by taking the derivative of the CDF with respect to x:

Step 3 – Expectation of X.max
We can then use the PDF to get the expectation of X.max as shown by:

Step 4 – Unbiased Estimation for D
Solving for D in terms of expectation gives us:

Therefore, the unbiased estimator of d, as denoted by d hat, is given by:
