Maximum likelihood estimator when $\sum_{j} \theta_j = 1$. How to impose this condition? I have a sample $x_1,\dots,x_n \stackrel{iid}{\sim}f(;\boldsymbol{\theta})$, where $\boldsymbol{\theta} = (\theta_1,\dots,\theta_d)$, and


*

*, $0<\theta_j<1$, 

*$\sum_{j=1}^d\theta_j = 1$.


I can easily implement and evaluate the log likelihood function
$$\ell(\boldsymbol{\theta}) = \sum_{i=1}^n \log f(x_i;\boldsymbol{\theta}),$$
however I do not know how to impose the condition 
$$\sum_{j=1}^d\theta_j = 1.$$
How is this kind of optimization done in maximum likelihood estimation?
 A: You can write it as a sum over every $\theta_i$ except the last one, and replace that term with $1 - \sum_{j=1}^{d-1}\theta_i$. 
If you also have boundaries (added, see comment), then you are in the realm of nonlinear contrained optimization, for which numerical and analytical approaches exist. Choices will depend on the actual $f$. There is  also the Lagrangian dual theorem which may be important in some cases. Perhaps you can look up a package in $R$ or $Python$ for maximum likelihood estimation and see how they do it. 
A: Another practical solution that is pretty popular, is to define $\boldsymbol{\theta} \in \mathbb{R}^d$, and then use some function to transform it to desired range, e.g. in your case, you could use softmax function
$$
\ell(\boldsymbol{\theta}) = \sum_{i=1}^n \log f\Big(x_i;\;\operatorname{softmax}(\boldsymbol{\theta})\Big)
$$
If you need the parameter to be non-negative, you could use $\exp$ function, etc. The idea is to have unrestricted parameter values, that are transformed using a deterministic function to desired range.
