In the second program you have:
> for (k in 1:K) {
> x = k + 0.0) / K;
> weights[k] = x^alpha * (1 - x)^beta;
> }
Which can't possibly compile due to the missing open paren defining x.
In the first you have:
> for (k in 1:K) {
> weights[k] = exp(beta_lpdf((k + 0.0) / K| alpha, beta));
> }
Those don't give you the same answer even if you fix the syntax.
If you look at the definition of the beta_lpdf you'll see that
there are gamma terms to normalize which aren't included in
your kernel-style version in the second program.
I don't know what you're trying to do---just saying they're not
the same program.
You can test this by just writing the function out and defining
the weights as generated quantities (or transformed parameters). You'd
see they are different.
- Bob
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.
> To post to this group, send email to
stan-...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.