예제 #1
0
파일: tutorials.py 프로젝트: gpamfilis/PGMS
# CPD we would using the transpose of it.
emission_prob = np.array([[0.045, 0.15, 0.2, 0.6, 0.005],
                          [0.2, 0.2, 0.2, 0.3, 0.1],
                          [0.3, 0.1, 0.1, 0.05, 0.45],
                          [0.1, 0.1, 0.2, 0.05, 0.55]])
# Setting the emission probability

model_multinomial.emissionprob_ = emission_prob
# model.sample returns both observations as well as hidden states
# the first return argument being the observation and the second
# being the hidden states
# Z, X = model_multinomial.sample(5)
#
# print('X',X)
#
# print('Z',Z)

states = [0]  #,1,2,3]
emisions = []

for state in states:
    em = []
    for i in range(100):
        em.append(model_multinomial._generate_sample_from_state(state)[0])
    emisions.append(em)  # print(state)
df = pd.DataFrame(emisions).T

df.plot(kind='hist')
plt.xticks([0, 1, 2, 3, 4])
plt.show()