Skip to content

The code is not numerical stable, it throws runtime warnings from time to time #85

@kunrenzhilu

Description

@kunrenzhilu

I test my model with the following setting and it throws an runtimewarning every time. I tested the model with the same setting in py2. Sometimes it's safe but sometimes the same error throws. The data is just some trajectories with state labels. range from 0 to 64*64-1. And total length of each observation is 8640.

Any hint on why it's not stable in py2 and not event work in py3?

/usr/local/lib/python3.5/dist-packages/scipy/stats/_distn_infrastructure.py:899: RuntimeWarning: divide by zero encountered in log
  return log(self._sf(x, *args))````

```python
Nmax = 24
obs_hypparams = {'K':64*64, 'alpha_0':64*64, 'alphav_0':np.ones((64*64,))} # K is the cardinality of the states, and the alpha is the prior trial.
dur_hypparams = {'alpha_0':8640, 'beta_0':2} # in beta interval, the event happens for alpha time

obs_distns = [distributions.Categorical(**obs_hypparams) for state in range(Nmax)]
dur_distns = [distributions.PoissonDuration(**dur_hypparams) for state in range(Nmax)]

categorical_post = pyhsmm.models.WeakLimitHDPHSMM(
        alpha_a_0=1., alpha_b_0=1./4,
        gamma_a_0=6., gamma_b_0=1./4,
        init_state_concentration=6.,
        obs_distns=obs_distns,
        dur_distns=dur_distns)

for i in range(10):
    categorical_post.add_data(hsmm_trajs[i], trunc=60)

from pyhsmm.util.text import progprint_xrange
import copy
models = []
for idx in progprint_xrange(20):
    categorical_post.resample_model(10)
    if (idx+1) % 10 == 0:
        models.append(copy.deepcopy(categorical_post))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions