2
DensityDist
を使用する前に均一なカスタム分布のサンプルを使用したいと思います。精神に何か:star
は非正規化対数尤度関数の2Dデカルトポイントをマッピングする関数であるPyMC3で多変量のサンプルをサンプリングする
import theano.tensor as T
from pymc3 import DensityDist, Uniform, Model
with Model() as model:
lim = 3
x0 = Uniform('x0', -lim, lim)
x1 = Uniform('x1', -lim, lim)
x = T.concatenate([x0,x1])
# Create custom densities
star = DensityDist('star', lambda x: star(x[:,0],x[:,1]))
。 Metropolis-Hastingsを使用してサンプルしたい機能です。
私はいくつかのバリエーションを試しましたが、うまくいきませんでした。現在のコードは次のエラーで失敗します:
ValueError: The index list is longer (size 2) than the number of dimensions of the tensor(namely 0). You are asking for a dimension of the tensor that does not exist! You might need to use dimshuffle to add extra dimension to your tensor.