I'm new to probability. Given the cumulative distribution function $f_Y(y)=\theta e^{-y\theta}$ defined from 0 to infinity, I would like to find the parameter $\theta$ such that it maximizes the likelihood function. I first thought that since PDF and CDF are strictly correlated between each other, I tried finding the first derivative of the CDF with respect to $\theta$: $$\frac{d}{d\theta}(\theta e^{-y\theta})=0 \implies \theta=\frac{1}{y}$$
Then I tried solving the PDF form the CDF: $$\frac{d}{dy}(\theta e^{-y\theta})=-\theta^2e^{-y\theta}$$ Which gives me the likelihood function for the continuous distribution. Naturally, I calculated the derivative with respect to $\theta$ of the likelihood function:
$$\frac{d}{d\theta}(-\theta^2e^{-y\theta})=0 \implies \theta=0 \vee \frac{2}{y}$$
My question is: why do I get two different values for $\theta$ with the two different approaches?
The textbook also suggests that for the sample $Y_1, ..., Y_n$, the MLE is $1/{\bar{Y_n}}$, which still is different from the two results I found. Can someone help me make some clarifications?