A financial formula that I am implementing requires that I find the first derivative of a function to find a local maxima, from scratch. Can someone please help me with finding the first derivative of this function:
$$ f(\theta) = -\log\left(\frac{1}{T}\sum_{t=1}^Te^{\theta r_t}\right)$$
I am able to simplify it to:
$$ f(\theta) = -\log\left( \sum e^{\theta\cdot r_t }\right) + \log (T) $$
And then I thought:
$$ f'(\theta) = -\frac{ \sum r_t\cdot e^{\theta\cdot r_t } }{ \sum e^{\theta\cdot r_t } } $$ But when real numbers are applied, they don't look right. Right sign but not value.
Update: After scouring a few sources of the formula, which are frustratingly all slightly different in some form or representation, and also taking a step back myself, I believe the issue is that theta is actually the variable. It was never expressed this way. I have update the formula to reflect this.