o
    0Gfz                     @   sn  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re.  e'e(de)ee edee dS dS )zWhat'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   7lib/python3.10/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__ZnumpyZnpr   r   r   Zscipyr   r   r   Zscipy.sparser   ZspeyeZmatplotlib.pyplotZpyplotZpltr   r   r   Zmmreadr
   shapenr   Z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@    




