B
    Z                 @   s~  d Z ddlmZ ddlZddlmZ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/Z0Z(Z)e(dkrze1  e*e+de,e e  edee" 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
    )print_functionN)dotouterrandomargsort)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rqZres r   6lib/python3.7/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   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)2__doc__Z
__future__r   ZnumpyZnpr   r   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:   




$
$
