亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

pymc3:具有多維濃度因子的狄利克雷

pymc3:具有多維濃度因子的狄利克雷

慕少森 2021-06-09 17:49:03
我正在努力實現一個模型,其中狄利克雷變量的集中因子取決于另一個變量。情況如下:系統因組件故障而失?。ㄓ腥齻€組件,每次測試/觀察只有一個失?。=M件失效的概率取決于溫度。這是該情況的(評論)簡短實現:import numpy as npimport pymc3 as pmimport theano.tensor as tt# Temperature data : 3 cold temperatures and 3 warm temperaturesT_data = np.array([10, 12, 14, 80, 90, 95])# Data of failures of 3 components : [0,0,1] means component 3 failedF_data = np.array([[0, 0, 1], \       [0, 0, 1], \       [0, 0, 1], \       [1, 0, 0], \       [1, 0, 0], \       [1, 0, 0]])n_component = 3# When temperature is cold : Component 1 fails# When temperature is warm : Component 3 fails# Component 2 never fails# Number of observations :n_obs = len(F_data)# The number of failures can be modeled as a Multinomial F ~ M(n_obs, p) with parameters # -  n_test : number of tests (Fixed)# -  p : probability of failure of each component (shape (n_obs, 3))# The probability of failure of components follows a Dirichlet distribution p ~ Dir(alpha) with parameters:# -  alpha : concentration (shape (n_obs, 3))# The Dirichlet distributions ensures the probabilities sum to 1 # The alpha parameters (and the the probability of failures) depend on the temperature alpha ~ a + b * T# - a : bias term (shape (1,3))# - b : describes temperature dependency of alpha (shape (1,3))_# The prior on "a" is a normal distributions with mean 1/2 and std 0.001# a ~ N(1/2, 0.001)# The prior on "b" is a normal distribution zith mean 0 and std 0.001# b ~ N(0, 0.001)# Coding it all with pymc3with pm.Model() as model:    a = pm.Normal('a', 1/2, 1/(0.001**2), shape = n_component)    b = pm.Normal('b', 0, 1/(0.001**2), shape = n_component)    # I generate 3 alphas values (corresponding to the 3 components) for each of the 6 temperatures    # I tried different ways to compute alpha but nothing worked out    alphas = pm.Deterministic('alphas', a + b * tt.stack([T_data, T_data, T_data], axis=1))    #alphas = pm.Deterministic('alphas', a + b[None, :] * T_data[:, None])    #alphas = pm.Deterministic('alphas', a + tt.outer(T_data,b))
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 138 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號