mjhajharia / transforms

2 stars 1 forks source link

Add transforms for log-simplex #71

Closed sethaxen closed 10 months ago

sethaxen commented 10 months ago

Following #65, this PR adds versions of our transforms for the log-simplex. It also adds a log-Dirichlet target.

Note that LogDirichlet(log_x | alpha) = Dirichlet(exp(log_x) | α) * exp(sum(log_x[1:(N-1)])), while the Jacobian corrections in the transforms are adjusted by exp(-sum(log_x[1:(N-1)])), i.e. in the opposite direction.

sethaxen commented 10 months ago

For some reason I haven't had any luck getting Stickbreaking with the log-simplex to be numerically stable.

sethaxen commented 10 months ago

For some reason I haven't had any luck getting Stickbreaking with the log-simplex to be numerically stable.

Turns out this was because the Jacobian determinant in the paper was off by an index. With the correct determinant, it works fine.

sethaxen commented 10 months ago

This PR also incorporates the changes in #72 and #73 but for the log-simplex.

bob-carpenter commented 10 months ago

The reference doc is here: https://mc-stan.org/docs/stan-users-guide/multi-indexing.html

Yes, it allocates an intermediate and copies. We're working on making it lazy with expression templates.

spinkney commented 10 months ago

LGTM!