updated log-density discussion

37 views
Skip to first unread message

Bob Carpenter

unread,
Jan 19, 2016, 2:40:24 AM1/19/16
to stan...@googlegroups.com
I tried to include all the relevant discussion from the lists
and include pros and cons as raised:

https://github.com/stan-dev/stan/wiki/Stan-3-Density-Notation-and-Increments

Argument by argument, I'm personally leaning toward:

* explicit suffixes for all probability-related functions

* default to normalized densities

* not getting clever with vertical bar

* going with just ld for the accumulator

* using += and switching assignment to = elsewhere

* Getting Daniel to write a translator because these models
are going to look way different

All in, the caterpillar we now write as

y ~ normal(mu, sigma);

transforms into the beautiful butterfly

ld += normal_lpdf<norm=false>(y, mu, sigma);

Hang on a second. I liked all those decisions until they
piled up into that trainwreck of a statement.

- Bob

Tamas Papp

unread,
Jan 19, 2016, 6:09:57 AM1/19/16
to stan...@googlegroups.com
I think that a lot of issues that are non-aesthetic (eg |, << vs +=)
revolve around choosing sensible defaults, or in other words, deciding
which use occurs frequently enough to warrant a shorter form.

Having read through the document in the wiki with this in mind, I
realized why I like the current syntax:

y ~ some_distribution(some_parameters);

is the kind of expression I need to write most often. I am not sure that
the language needs be super-explicit about emphasizing that we are in
fact incrementing a log density, in every single line.

I could also live with

some_distribution(y | some_parameters);

with the understanding that for statements that are not assignments or
shorthand for assignments (eg var+=), ld+= is assumed without making it
explicit.

Regarding <> keyword arguments: I am under the impression that blocks of
normalized statements tend to occur frequently in the same
block/expression. So one could introduce a prefix like

normalized [expression];

eg

normalized cauchy_lpdf(y | mu, tau);

or

normalized {
...a block of multiple such statements...
}

Similarly for vectorized, eg

log_lik <- normalized vector normal(y | mu, tau);

instead of

log_lik <- normal_lpdf<norm=true,vector=true>(y | mu, tau);

But I don't know how much this would complicate the parser.

Anyway, I think it would be instructive to have an example page of 2-5
programs that demonstrate the shortcomings of current syntax, and then
rewrite them with proposed syntaxes (rewriting done by those who make a
proposal for a syntax).

Best,

Tamas

Michael Betancourt

unread,
Jan 19, 2016, 7:54:12 AM1/19/16
to stan...@googlegroups.com
Whoa, whoa, whoa.  What happened to the bar and making
the normalization false be default?

ld += normal_lpdf(y | mu, sigma)

looks pretty clean to me.

Ben Goodrich

unread,
Jan 19, 2016, 9:55:22 AM1/19/16
to stan development mailing list
On Tuesday, January 19, 2016 at 7:54:12 AM UTC-5, Michael Betancourt wrote:
Whoa, whoa, whoa.  What happened to the bar and making
the normalization false be default?

ld += normal_lpdf(y | mu, sigma)

looks pretty clean to me.

I like this too.

Ben

Krzysztof Sakrejda

unread,
Jan 19, 2016, 10:14:01 AM1/19/16
to stan development mailing list
+1
Reply all
Reply to author
Forward
0 new messages