@@ -283,6 +283,8 @@ def visualize_model(self,sample_size=100):
283
283
>>> from bayesml import gaussianmixture
284
284
>>> import numpy as np
285
285
>>> model = gaussianmixture.GenModel(
286
+ >>> c_num_classes=3,
287
+ >>> c_degree=1
286
288
>>> pi_vec=np.array([0.444,0.444,0.112]),
287
289
>>> mu_vecs=np.array([[-2.8],[-0.8],[2]]),
288
290
>>> lambda_mats=np.array([[[6.25]],[[6.25]],[[100]]])
@@ -763,11 +765,11 @@ def _init_subsampling(self,x):
763
765
for k in range (self .c_num_classes ):
764
766
_subsample = self .rng .choice (x ,size = _size ,replace = False ,axis = 0 ,shuffle = False )
765
767
self .hn_m_vecs [k ] = _subsample .sum (axis = 0 ) / _size
766
- self .hn_w_mats [k ] = ((_subsample - self .hn_m_vecs [k ]).T
768
+ self .hn_w_mats_inv [k ] = ((_subsample - self .hn_m_vecs [k ]).T
767
769
@ (_subsample - self .hn_m_vecs [k ])
768
- / _size / self .hn_nus [k ]
770
+ / _size * self .hn_nus [k ]
769
771
+ np .identity (self .c_degree ) * 1.0E-5 ) # avoid singular matrix
770
- self .hn_w_mats_inv [k ] = np .linalg .inv (self .hn_w_mats [k ])
772
+ self .hn_w_mats [k ] = np .linalg .inv (self .hn_w_mats_inv [k ])
771
773
self ._calc_q_pi_char ()
772
774
self ._calc_q_lambda_char ()
773
775
0 commit comments