# Deriving the un-normalized log posterior on sigma

Hello I'm trying to derive the un-normalized log posterior on sigma this is what I have so far $$p \left(\sigma \mid \mathbf{x}, \mu\right) \propto \log \left( p \left(\sigma \mid \mathbf{x}, \mu\right) \propto \right) = \sum_{n=1}^N \left( \log \left( \mathrm{normal}\left( x_n \mid \mu, \sigma \right) \right) \right)$$

$$\sum_{n=1}^N \left( \log \left( \mathrm{normal}\left( x_n \mid \mu, \sigma \right) \right) \right) = \sum_{n=1}^N \left( \log \left( \left( \frac{1}{\sqrt{2\pi\sigma^2}}\right) \mathrm{exp} \left( - \frac{1}{2\sigma^2} \right) \left( x_n - \mu^2 \right) \right) \right)$$

$$= \sum_{n=1}^N \left( -\frac{1}{2} \log\left( 2\pi \right) -\frac{1}{2} \log\left( 2\sigma^2 \right) - \frac{1}{2\sigma^2} \left( x_n - \mu^2 \right) \right)$$

Dropping the terms that don't involve sigma: $$\sum_{n=1}^N \left( -\frac{1}{2} \log\left( 2\sigma^2 \right) - \frac{1}{2\sigma^2} \left( x_n - \mu^2 \right) \right)$$

and then taking the partial derivative w.r.t $$\sigma$$

$$\frac{\partial}{\partial\sigma}\sum_{n=1}^N \left( -\frac{1}{2} \log\left( 2\sigma^2 \right) - \frac{1}{2\sigma^2} \left( x_n - \mu^2 \right) \right) = \sum_{n=1}^{N} -\frac{1}{\sigma} - \left( x-\mu \right)^2 \frac{1}{\sigma^3}$$

Simplifying sum as N

$$-\frac{N}{\sigma} - \frac{N\left( x- \mu \right)^2}{\sigma^3} = - \frac{N}{\sigma} \left( 1 + \frac{\left( x-\mu \right)^2}{\sigma^2} \right)$$

and then setting this equal to zero $$\sigma^2 = - \left( x-\mu \right)^2$$

I'm trying to follow along with notes I have but I think I'm making a mistake somewhere. Any help would be very appreciated thanks