ó
áp7]c           @  s  d  Z  d d l m Z d d l Z d d l m Z m Z m Z d d l m	 Z	 m
 Z
 m Z d d l m Z d d l j Z d „  Z d „  Z d	 „  Z e	 j d
 ƒ Z e j d Z e e e ƒ Z e j d ƒ e j e ƒ Z e d ƒ d Z g  Z e j  e e d e d e d d ƒ\ Z! Z" Z# Z$ Z% Z& Z' Z( e' d k rqe j) e j* d e+ e ƒ ƒ e ƒ e d e e! ƒ ƒ n  e d ƒ e d ƒ g  Z e j, e e d e d e d e d d ƒ\ Z! Z" Z- Z. Z/ Z' Z( e' d k re j0 ƒ  e j) e j* d e+ e ƒ ƒ e ƒ e d e e! ƒ ƒ n  d S(   sª   What's the origin of this file? It is not ours.
Does not run because of missing mtx files, now included

changes: JP corrections to imports so it runs, comment out print
iÿÿÿÿ(   t   print_functionN(   t   dott   outert   random(   t   iot   linalgt   optimize(   t   eyec         C  sk   t  |  j t |  ƒ t  |  j t |  ƒ } t |  | t |  t j t |  ƒ } t j t j | ƒ ƒ | S(   N(   R   t   Tt   At   BR   t   normt   datat   append(   t   vt   rqt   res(    (    s6   lib/python2.7/site-packages/statsmodels/sandbox/mle.pyt   R   s    *'c         C  s8   d t  |  t |  ƒ t |  t |  j t |  ƒ } | S(   s
    Gradient i   (   R	   R   R
   R   R   (   R   t   result(    (    s6   lib/python2.7/site-packages/statsmodels/sandbox/mle.pyt   Rp   s    4c         C  s^   d t  t |  ƒ t t t |  t |  ƒ ƒ t t |  ƒ t |  ƒ t |  j t |  ƒ } | S(   s	    Hessian i   (   R	   R   R
   R   R   R   R   (   R   R   (    (    s6   lib/python2.7/site-packages/statsmodels/sandbox/mle.pyt   Rpp   s    Zs   nos4.mtxi    i   s   try fmin_bfgst   fprimet   full_outputt   retalls   Rayleigh quotient BFGSs   fmin_bfgs OKs   try fmin_ncgt   fhesss   Rayleigh quotient NCG(1   t   __doc__t
   __future__R    t   numpyt   npR   R   R   t   scipyR   R   R   t   scipy.sparseR   t   speyet   matplotlib.pyplott   pyplott   pltR   R   R   t   mmreadR	   t   shapet   nR
   t   seedt   randt   v_0t   printR   R   t	   fmin_bfgsR   t   foptt   goptt   Hoptt
   func_callst
   grad_callst   warnflagt   allvecst   semilogyt   aranget   lent   fmin_ncgt   fcallst   gcallst   hcallst   figure(    (    (    s6   lib/python2.7/site-packages/statsmodels/sandbox/mle.pyt   <module>   s:   			
<"

?
"