U
    Ãmœdz  ã                   @   sl  d 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mZ dd„ Zdd	„ Zd
d„ Ze d¡Zejd ZeeeƒZe d¡ e e¡Zedƒ dZg Ze	jeeeedd�\ZZ Z!Z"Z#Z$Z%Z&e%dkrøe 'e (de)eƒ¡e¡ edeeƒƒ edƒ edƒ g Ze	j*eeeeedd�\ZZ Z+Z,Z-Z%Z&e%dk�rhe .¡  e 'e (de)eƒ¡e¡ edeeƒƒ dS )zª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
é    N)ÚdotÚouterÚrandom)ÚioÚlinalgÚoptimize)Úeyec                 C   sV   t | jt|  ƒt | jt|  ƒ }t|  |t |   t t|  ¡ }t t |¡¡ |S )N)r   ÚTÚAÚBr   ZnormÚdataÚappend)ÚvZrqÚres© r   úP/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/sandbox/mle.pyÚR   s     "r   c                 C   s0   dt |  t| ƒt |    t| jt|  ƒ }|S )z
 Gradient é   )r
   r   r   r   r	   ©r   Úresultr   r   r   ÚRp   s    ,r   c                 C   sL   dt t| ƒt  tt|  t| ƒƒ tt| ƒt|  ƒ  t| jt|  ƒ }|S )z	 Hessian r   )r
   r   r   r   r   r   r	   r   r   r   r   ÚRpp   s    Hr   znos4.mtxé   ztry fmin_bfgs)ÚfprimeÚfull_outputÚretallzRayleigh quotient BFGSzfmin_bfgs OKztry fmin_ncg)r   Zfhessr   r   zRayleigh quotient NCG)/Ú__doc__ÚnumpyÚnpr   r   r   Zscipyr   r   r   Zscipy.sparser   ZspeyeZmatplotlib.pyplotZpyplotZpltr   r   r   Zmmreadr
   ÚshapeÚnr   ÚseedZrandZv_0Úprintr   r   Z	fmin_bfgsr   ZfoptZgoptZHoptZ
func_callsZ
grad_callsZwarnflagZallvecsZsemilogyZarangeÚlenZfmin_ncgZfcallsZgcallsZhcallsZfigurer   r   r   r   Ú<module>   s<   




ÿÿ
