Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent fac == 0 in hmm.smoother #66

Open
camrinbraun opened this issue Feb 27, 2022 · 2 comments
Open

Prevent fac == 0 in hmm.smoother #66

camrinbraun opened this issue Feb 27, 2022 · 2 comments
Assignees

Comments

@camrinbraun
Copy link
Owner

From Dr. Itoh:

When fac become too low, error occur and the program stop. I added a sentence and prevent to the fac become zero. I don't know the statistical accuracy of this measure. I am doing so tentatively to get the calculated value.

<>

    else {

        post1 <- post1 * f$phi[1, t - 1, , ]

        post2 <- post2 * f$phi[2, t - 1, , ]

        fac <- sum(as.vector(post1)) + sum(as.vector(post2))

        smooth[1, t - 1, , ] <- post1/fac

        smooth[2, t - 1, , ] <- post2/fac

<>

        post1 <- post1 * f$phi[1, t - 1, , ]

        post2 <- post2 * f$phi[2, t - 1, , ]

        fac <- sum(as.vector(post1)) + sum(as.vector(post2))

        if(fac< 1e-200) {

               fac <- 1e-200       #added to prevent fac=0 which cause error.

        }

        smooth[1, t - 1, , ] <- post1/fac

        smooth[2, t - 1, , ] <- post2/fac
@camrinbraun
Copy link
Owner Author

@marosteg @galuardi have you had this issue?

@marosteg
Copy link
Collaborator

I've never run into that problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants