You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to model some data with a negative binomial duration distribution...the /util/cstats/sample_crp_tablecounts function was failing because its second argument integral[:,:] customers was being passed in as a float. The numbers being passed in appear to be durations in n_samples, so they're guaranteed to be integers, so I fixed by changing line 31 in pyhsmm/distributions (within the _StartAtOneMixin.resample() method) from return super(_StartAtOneMixin,self).resample(data-1, *args,**kwargs)
to return super(_StartAtOneMixin,self).resample((data-1).astype('int'), *args,**kwargs).
If I have time I'll try to track down what caused the error in the first place.
*** Code to reproduce ***
data = np.arange(10).reshape(-1,1)
Nmax = 25
# and some hyperparameters
obs_dim = data.shape[1]
obs_hypparams = {'mu_0':np.zeros(obs_dim),
'sigma_0':np.eye(obs_dim),
'kappa_0':0.25,
'nu_0':obs_dim+2}
obs_distns = [pyhsmm.distributions.Gaussian(**obs_hypparams) for state in range(Nmax)]
dur_hypparams = {'r':3., 'p':0.5, 'k_0':2., 'theta_0':2., 'alpha_0':2., 'beta_0':2.}
dur_distns = [pyhsmm.distributions.NegativeBinomialDuration(**dur_hypparams) for state in range(Nmax)]
posteriormodel = pyhsmm.models.WeakLimitHDPHSMM(
alpha=6.,gamma=6., # these can matter; see concentration-resampling.py
init_state_concentration=6., # pretty inconsequential
obs_distns=obs_distns,
dur_distns=dur_distns)
posteriormodel.add_data(data, trunc=60) # duration truncation speeds things up when it's possible
for idx in progprint_xrange(150):
posteriormodel.resample_model()
*** Traceback from error ***
TypeError Traceback (most recent call last)
/tmp/ipykernel_16301/156295421.py in
35
36 for idx in progprint_xrange(150):
---> 37 posteriormodel.resample_model()
~/datta-lab/pyhsmm/pyhsmm/basic/distributions.py in resample(self, data, *args, **kwargs)
33 else:
34 # return super(_StartAtOneMixin,self).resample([(d-1).astype('int') for d in data],*args,**kwargs)
---> 35 return super(_StartAtOneMixin,self).resample([d-1 for d in data],*args,**kwargs)
36
37 def max_likelihood(self,data,weights=None,*args,**kwargs):
~/miniconda3/envs/dataPy_NWB/lib/python3.9/site-packages/pybasicbayes/distributions/negativebinomial.py in resample(self, data, niter)
113 for itr in range(niter):
114 ### resample r
--> 115 msum = sample_crp_tablecounts(self.r,data).sum()
116 self.r = np.random.gamma(self.k_0 + msum, 1/(1/self.theta_0 - N*np.log(1-self.p)))
117 ### resample p
pybasicbayes/util/cstats.pyx in pybasicbayes.util.cstats.__pyx_fused_cpdef()
TypeError: Function call with ambiguous argument types
The text was updated successfully, but these errors were encountered:
Trying to model some data with a negative binomial duration distribution...the /util/cstats/sample_crp_tablecounts function was failing because its second argument
integral[:,:] customers
was being passed in as a float. The numbers being passed in appear to be durations in n_samples, so they're guaranteed to be integers, so I fixed by changing line 31 in pyhsmm/distributions (within the_StartAtOneMixin.resample() method
) fromreturn super(_StartAtOneMixin,self).resample(data-1, *args,**kwargs)
to
return super(_StartAtOneMixin,self).resample((data-1).astype('int'), *args,**kwargs)
.If I have time I'll try to track down what caused the error in the first place.
*** Code to reproduce ***
*** Traceback from error ***
The text was updated successfully, but these errors were encountered: