quick nan-error related question

41 views
Skip to first unread message

Alp Kucukelbir

unread,
Oct 31, 2014, 3:05:15 PM10/31/14
to stan...@googlegroups.com
hi folks,

does an error like this mean something specific to any of you?

"
Exception: stan::prob::gamma_log(N4stan5agrad3varE): Random variable[1] is nan:0, but must not be nan!
Diagnostic information:
Dynamic exception type: St12domain_error
std::exception::what: stan::prob::gamma_log(N4stan5agrad3varE): Random variable[1] is nan:0, but must not be nan!
"

i'm trying to pinpoint where things are going awry. should "N4stan5agrad3varE" mean something to me?

thanks for the help.

cheers,
alp

Ben Goodrich

unread,
Oct 31, 2014, 3:32:13 PM10/31/14
to stan...@googlegroups.com
The N4stan5agrad3varE doesn't mean anything I don't think. The gamma_log() function received a nan value on input. If that doesn't happen on the first function evaluation, then it usually means the previous gradient calculation went nan somehow and then the next proposal went nan because it is a function of the previous gradient.

Ben

Alp Kucukelbir

unread,
Oct 31, 2014, 4:39:09 PM10/31/14
to stan...@googlegroups.com
thanks Ben.

i'm hunting it down...

cheers,
alp
> --
> You received this message because you are subscribed to a topic in the Google Groups "stan development mailing list" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-dev/ZedLrYnjRyQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Daniel Lee

unread,
Oct 31, 2014, 4:59:16 PM10/31/14
to stan...@googlegroups.com
are you on a Windows machine? "N4stan5agrad3varE" is your system trying to print the type of Stan's autodiff variable.

So... it's either a parameter, transformed parameter, or local variable in the transformed parameters or model block that's causing that issue.



You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.

Bob Carpenter

unread,
Oct 31, 2014, 8:22:34 PM10/31/14
to stan...@googlegroups.com

> On Oct 31, 2014, at 3:05 PM, Alp Kucukelbir <akucu...@gmail.com> wrote:
>
> hi folks,
>
> does an error like this mean something specific to any of you?
>
> "
> Exception: stan::prob::gamma_log(N4stan5agrad3varE): Random variable[1] is nan:0, but must not be nan!
> Diagnostic information:
> Dynamic exception type: St12domain_error
> std::exception::what: stan::prob::gamma_log(N4stan5agrad3varE): Random variable[1] is nan:0, but must not be nan!
> "

There's a sampling statement y ~ gamma(alpha,beta) or function call gamma_log(y,alpha,beta)
where y is NaN. Usually this will only happen if you try to use a local variable before
it's defined, or divide 0 by 0, or subtract infinity from infinity or the like.

Are you up to date with the latest release? I think the : went away,
but "nan:0" is just the value:adjoint, and all adjoints are initialized
to 0 for autodiff variables.

> i'm trying to pinpoint where things are going awry. should "N4stan5agrad3varE" mean something to me?

C++ mangles names, that's telling you that the scalar type is
stan::agrad::var.

Daniel's working on making these messages more interpretable right now.

- Bob

Bob Carpenter

unread,
Oct 31, 2014, 8:23:19 PM10/31/14
to stan...@googlegroups.com
Sorry --- had my mail scrolled to where I didn't see the earlier
replies.

- Bob

Alp Kucukelbir

unread,
Nov 1, 2014, 8:08:44 AM11/1/14
to stan...@googlegroups.com
hi folks,

i just merged the feature/ppvb branch with develop. so i think i'm up to date.

i'll continue putting some checks around my gradient computations to see if any of these cases ever occur.

thanks for the tips, guys.

however, just for the record: as a gentlemen of high bearing, my heraldry dictates that i must invite daniel to a duel to the death. for no one has ever devised, let alone delivered, such a caustic insult during my time on this land. i cannot have the populace believe that it is acceptable to ask me (*me!*) whether i use windows.

Reply all
Reply to author
Forward
0 new messages