Python で多変数 ln 関数をプロットする必要があります。プロットは、領域 x 1 , x 2 ∈ [−5, 5] 上の ln (L 1 (x 1 , x 2 )) を示します。モデルの縮退は、ln L 1 の値が変化しない x 1 -x 2 平面の線として表示されます。
線形関数の仕事をするチュートリアルに従いました。:
from __future__ import division
from numpy import exp,arange
from pylab import meshgrid,cm,imshow,contour,clabel,colorbar,axis,title,show
import matplotlib.pyplot as plt
from matplotlib import pylab
from numpy import arange,array,ones
from scipy import stats
import numpy
import sys
import os
import matplotlib.pyplot as plt
from pylab import *
import math
# the function that I'm going to plot
def z_func(x1,x2):
return exp(-(1-x1)**2 - 100*((x2-x1**2)**2))
x1 = linspace(-5.0,5.0,1000)
x2 = linspace(-5.0,5.0,1000)
X1,X2 = meshgrid(x1, x2) # grid of point
Z = z_func(X1, X2) # evaluation of the function on the grid
im = imshow(Z,cmap=cm.RdBu) # drawing the function
# adding the Contour lines with labels
#cset = contour(Z,arange(-1,1.5,0.2),linewidths=2,cmap=cm.Set2)
#clabel(cset,inline=True,fmt='%1.1f',fontsize=10)
#colorbar(im) # adding the colobar on the right
# latex fashion title
title('$L = exp(-(1-x_{1})^2 - 100(x_{2}-x_{1}^2)^2)$')
show()
生成された画像も添付されていますが、これはまだ私にはあまりわかりません。
どうすればそれを ln ベースの plot に変更できるのだろうと思っていました。また、プロットに x および y ラベルを追加する必要があります