Blockhead3 / Dilichlet-process-mixture

0 stars 0 forks source link

Mixed multivariate Gauss distribution #1

Open Blockhead3 opened 6 years ago

Blockhead3 commented 6 years ago

Hello,I want to carry out a sampling of the multiple Gauss mixed model,The distribution of variables is as follows:

Mixed multivariate Gauss distribution

_yi=∑(k=1)^K{ω_kN(0,σ_k^2 H(ρk ))} ----multivariate Gauss distribution mixture _ω_k=β_k∏_(j=1)^(k-1){1-βj } ----weights,stick-breaking process _β_i iid Beta(1,M) σ_k iid U(0,1.5)--prior ρk iid U(0,1)--prior

The following is the code

import numpy as np import pymc3 as pm from theano import tensor as tt

K=6 # the number of components N=200 #the number of observed individuals n=9 #each individual was observed 9 times

mu0=np.linspace(0.0,0.0,num=n)

simulate observation data

C1=np.zeros((n,n)) for i in range(0,n): for j in range(0,n): if i==j: C1[i,j]=10.0 else: C1[i,j]=7.0

dataSet1=np.random.multivariate_normal(mu0,C1,size=N)

observation time(all individuals are observed at the same times)

time_obseved=[-5.0,-4.5,-3.0,-2.5,-1.0,0.0,1.5,2.5,3.0,4.0,5.5] time=np.array(time_obseved)

def H(rho): H=np.zeros((n,n)) for i in range(0,n): for j in range(0,n): H[i,j]=np.power(rho,np.abs(time[j]-time[i])) return H

stick-breaking process

def stick_breaking(beta): portion_remaining = tt.concatenate([[1], tt.extra_ops.cumprod(1 - beta)[:-1]])

return beta * portion_remaining

with pm.Model() as model:

M=pm.Gamma('M',1.,1.)

sigma_w=pm.Uniform('sigma_w',0.0,1.5,shape=K)
rho=pm.Uniform('rho',0.0,0.1,shape=K)

beta=pm.Beta('beta',1.,M,shape=K)
w=pm.Deterministic('w',stick_breaking(beta))

obs=pm.Mixture('obs',w,pm.MvNormal.dist(mu=mu0,cov=sigma_w**2*H(rho)),observed=dataSet1)

it's not work, Can you give me a hint how to consider it for a multi mixture @junpenglao,thanks.

junpenglao commented 6 years ago

Please post to our discourse, I will answer you there. Thanks!

Blockhead3 commented 6 years ago

Thank you for answering me in your busy schedule, and I will try to put the question to the forum.

------------------ 原始邮件 ------------------ 发件人: "Junpeng Lao"notifications@github.com; 发送时间: 2018年3月26日(星期一) 晚上6:41 收件人: "Blockhead3/Dilichlet-process-mixture"Dilichlet-process-mixture@noreply.github.com; 抄送: "☆_偏执的傻瓜"1799800494@qq.com; "Author"author@noreply.github.com; 主题: Re: [Blockhead3/Dilichlet-process-mixture] Mixed multivariate Gaussdistribution (#1)

Please post to our discourse, I will answer you there. Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.