PyStan 為 Stan 提供了一個(gè) Python 接口,這是一個(gè)使用 No-U-Turn 采樣器進(jìn)行貝葉斯推理的軟件包,這是Hamiltonian Monte Carlo 的一種變體。
PyStan具有以下依賴項(xiàng):
Python:2.7,> = 3.3
Cython:> = 0.22
NumPy:> = 1.7
PyStan還要求在安裝和運(yùn)行時(shí)可以使用C ++編譯器。 在基于Debian的系統(tǒng)上,這是通過(guò)發(fā)出命令apt-get install build-essential來(lái)完成的。
例子:
import pystan schools_code = """ data { int<lower=0> J; // number of schools vector[J] y; // estimated treatment effects vector<lower=0>[J] sigma; // s.e. of effect estimates } parameters { real mu; real<lower=0> tau; vector[J] eta; } transformed parameters { vector[J] theta; theta = mu + tau * eta; } model { eta ~ normal(0, 1); y ~ normal(theta, sigma); } """schools_dat = {'J': 8, 'y': [28, 8, -3, 7, -1, 1, 18, 12], 'sigma': [15, 10, 16, 11, 9, 11, 10, 18]} sm = pystan.StanModel(model_code=schools_code) fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
需要資料,看個(gè)簡(jiǎn)介
素材來(lái)源中:開(kāi)源中國(guó)
新聞標(biāo)題:Python中的貝葉斯推理的軟件包pystan-創(chuàng)新互聯(lián)
瀏覽地址:http://www.ekvhdxd.cn/article12/dojgdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、關(guān)鍵詞優(yōu)化、小程序開(kāi)發(fā)、微信公眾號(hào)、網(wǎng)站建設(shè)、App開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容