lines 8-87 of file: example/python/mixed/hes_fixed_obj_xam.py {xrst_begin mixed_hes_fixed_obj_xam.py} {xrst_spell laplace } ran_likelihood: Example and Test ################################ p(y|theta, u) ************* In this example math:`y` given :math:`( \theta , u )` is distributed normally with mean :math:`\bar{y} + u` and variance :math:`\theta`; i.e. .. math:: - \log [ \B{p} ( y | \theta , u ) ] = \log \left[ \sqrt{ 2 \pi \theta } \right] + \frac{1}{2} ( y - \bar{y} - u )^2 / \theta p(u|theta) ********** In this example, the prior for :math:`u` given :math:`\theta` is a normal with mean zero and standard deviation :math:`\sigma`; i.e. .. math:: - \log [ \B{p} ( u | \theta ) ] = \log \left[ \sqrt{ 2 \pi \sigma^2 } \right] + \frac{1}{2} u^2 / \sigma^2 p(y|theta) ********** For this example, Laplace approximation is equal to :math:`\B{p}(y|\theta)` i.e, it is exact. Furthermore, .. math:: - \log[ \B{p}(y|\theta) ] = \log \left[ \sqrt{ 2 \pi ( \theta + \sigma^2) } \right] + \frac{1}{2} ( y - \bar{y} )^2 / ( \theta + \sigma^2 ) Derivative ********** For this example there is no fixed effects likelihood or constraints. Hence the derivative of the fixed effects objective, w.r.t the fixed effects :math:`\theta`, is .. math:: \frac{1}{2} ( \theta + \sigma^2 )^{-1} - \frac{1}{2} ( y - \bar{y} )^2 ( \theta + \sigma^2 )^{-2} Hessian ******* Taking the derivative of the expression above w.r.t the fixed effects :math:`\theta` we obtain the Hessian: .. math:: ( y - \bar{y} )^2 ( \theta + \sigma^2 )^{-3} - \frac{1}{2} ( \theta + \sigma^2 )^{-2} {xrst_literal # BEGIN SOURCE # END SOURCE } {xrst_end mixed_hes_fixed_obj_xam.py}