# Differential of sum of logs of probabilities

I'm trying to calculate the derivative with respect to $$p1$$, $$p2$$, ... $$pk$$ (each) of the following equation: $$L = N_1 \log p_1 + N_2 \log p_2 + ... N_k \log p_k$$

where $$\Sigma_{i=1}^k p_i = 1$$

i.e. I need to find $$\partial L / \partial p_i$$ for $$i = 1, 2, ... k$$

Since all the $$p_i$$'s are interdependent, how do I calculate the derivative? With k=2 it is possible to write $$p_1 = p$$ and $$p_2 = 1 - p$$, and differentiate with respect to $$p$$ but how do I do it for the general case?

Note: the $$N_i$$'s are constants

• You could try Lagrange multipliers – Robin Nicole May 15 at 7:43

Write it as $$L=\sum _{j=1}^n N_j \log \left(\frac{p_j}{\sum _{i=1}^n p_i}\right)$$ and derive. Reusing later that $$\sum _{i=1}^n p_i=1$$, you should get for example $$\frac{\partial L}{\partial p_1}=-(N_2+N_3+\cdots+ N_n)+N_1\frac {1-p_1}{p_1}=\frac{N_1}{p_1}-\sum _{i=1}^n N_i$$ So $$\frac{\partial L}{\partial p_k}=\frac{N_k}{p_k}-\sum _{i=1}^n N_i$$