------------------------------------------------- lines 5-78 of file: example/user/ill_condition.py ------------------------------------------------- # {xrst_begin user_ill_condition.py} # {xrst_comment_ch #} # # An Ill Conditioned Example Where Re-Scaling is Helpful # ###################################################### # # Notation # ******** # # .. csv-table:: # :widths: auto # # :math:`\bar{\chi}`,measured value for excess mortality at age zero # :math:`\sigma`,std for the measurement noise # :math:`\delta`,std for age difference for :math:`\chi` # :math:`\chi_0`,estimate for :math:`\chi` at age zero # :math:`\chi_1`,estimate for :math:`\chi` at age 100 # # Objective # ********* # For this case the negative log likelihood is, not counting terms # that are constant w.r.t :math:`( \chi_0, \chi_1 )`, # # .. math:: # # f( \chi_0 , \chi_1 ) # = # \frac{1}{2} \left( \frac{\chi_0 - \bar{\chi}}{\sigma} \right)^2 # + # \frac{1}{2} \left( \frac{\chi_1 - \chi_0}{\delta} \right)^2 # # Derivative # ********** # The partial of the objective w.r.t. :math:`\chi_0` is # # .. math:: # # \partial_0 f ( \chi_0 , \chi_1 ) # = # \frac{\chi_0 - \bar{\chi}}{ \sigma^2 } # - # \frac{\chi_1 - \chi_0}{\delta^2} # # The partial of the objective w.r.t. :math:`\chi_1` is # # .. math:: # # \partial_1 f ( \chi_0 , \chi_1 ) # = # \frac{\chi_1 - \chi_0}{\delta^2} # # Ill-Conditioning # **************** # If :math:`\sigma` is much smaller than :math:`\delta`, # then the optimization problem will weight the measurement equation # :math:`\chi_0 - \bar{\chi} = 0` much more than the difference equation # :math:`\chi_1 - \chi_0 = 0`. # If :math:`\sigma` is much larger than :math:`\delta`, # then the optimization problem will weight the difference equation # much more than the measurement equation. # # Scaling # ******* # Note that the initial scaling, in the example below, uses the # mean values for :math:`\chi_0`, :math:`\chi_1` which are zero. # # Source Code # *********** # {xrst_literal # BEGIN PYTHON # END PYTHON # } # # {xrst_end user_ill_condition.py}