sampling from final variational approximation

63 views
Skip to first unread message

Alp Kucukelbir

unread,
Apr 11, 2015, 4:31:02 PM4/11/15
to stan...@googlegroups.com
hi all,

sorry for the many messages, but i think i'm going to need this for the journal version of the paper that we're writing up right now.

what is "this"? for ADVI it's a function that takes in a multivariate Gaussian over the parameters, draws a bunch of points from said Gaussian, and pushes the samples through transformations defined by a model.

so i think this puts me in the position of implementing this. i was wondering if i should start from scratch or if anyone has written anything towards this goal.

apologies in advance if i missed any discussion around this in the past few weeks/months.

cheers
alp

Bob Carpenter

unread,
Apr 11, 2015, 9:48:57 PM4/11/15
to stan...@googlegroups.com
We need that for MLE and MML, too. The one you want to
coordinate with is Rob Trangucci, who's in charge of the MLE
and MML efforts.

The code should probably go somewhere more general than in
with VB, like in the model utility class.

I'm happy to chime in on design, but it should be relatively
simple. We have the multi_normal_rng function already defined.
And the transform is available through the generated model code,
though it's not pretty to use standalone.

What we really need to do is change the model, which currently
uses the method write_array to convert the array of unconstrained
parameters to an array of constrained parameters. Then there
are methods to pull out the parameter names and sizes/dimesnions
in the order they're generated by the model. Just be careful to
keep in mind it's last-index major (column major for matrices).

- Bob
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

Michael Betancourt

unread,
Apr 12, 2015, 6:04:43 AM4/12/15
to stan...@googlegroups.com
More specifically,

// Get constrained parameter names
std::vector<std::string> names;
model.constrained_param_names(names, true, true);

// construct mean, mu, and covariance, C.
L = cholesky(C);
for (int n = 0; n < size; ++n) z(n) = normal_rng(0, 1);
q = L* z + mu;

model.write_array(rng,
q, // Input unconstrained values
model_values, // Output constrained values
true, true,
msg_stream_);

Bob Carpenter

unread,
Apr 12, 2015, 8:16:58 PM4/12/15
to stan...@googlegroups.com
Good point --- using the Cholesky parameterization is much better than
using multi_normal_rng(). There are examples of just this in the GP
section of the manual.

Is it possible to do even better somehow by rescaling uniform(0,1) variates
directly? I know you can do inverse CDFs, but that's unlikely to be a
computational win over normal_rng() or Boost would've implemented normal
RNGs that way.

- Bob

Alp Kucukelbir

unread,
Apr 13, 2015, 8:23:18 AM4/13/15
to stan...@googlegroups.com
we implemented the gaussian variational approximation in advi
as michael describes. that's the state of the art, as far as i know.

michael's template is what i had in mind as well. i think i'm going
to take a shot at this fairly soon. i'm not sure how do to this with
the current pull request for feature/bbvb though... should i create
a branch off of feature/bbvb?

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/TRMdaP25NXM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to stan-dev+u...@googlegroups.com.

Daniel Lee

unread,
Apr 13, 2015, 8:27:18 AM4/13/15
to stan...@googlegroups.com
On Mon, Apr 13, 2015 at 8:23 AM, Alp Kucukelbir <akucu...@gmail.com> wrote:
we implemented the gaussian variational approximation in advi
as michael describes. that's the state of the art, as far as i know.

michael's template is what i had in mind as well. i think i'm going
to take a shot at this fairly soon. i'm not sure how do to this with
the current pull request for feature/bbvb though... should i create
a branch off of feature/bbvb?

Yes, that should be the starting point.




Ben Goodrich

unread,
Apr 13, 2015, 4:53:26 PM4/13/15
to stan...@googlegroups.com
On Sunday, April 12, 2015 at 8:16:58 PM UTC-4, Bob Carpenter wrote:
Is it possible to do even better somehow by rescaling uniform(0,1) variates
directly?  I know you can do inverse CDFs, but that's unlikely to be a
computational win over normal_rng() or Boost would've implemented normal
RNGs that way.

R implements rnorm() that way these days.

Ben
Reply all
Reply to author
Forward
0 new messages