Dear Stan users,

I am in the early stages of writing a model for analyzing data with a user-defined prior distribution.

As a first step, I want to make sure that I can write a Stan program that can sample from my prior distribution f

where f(t) is proportional to t^2 on the domain (0, d), where d will be specified through the data list.

My stan code is as follows. For the record, note that I run with d=1.3 and inits=list(t=1).

functions

{

real lowertriangle_lpdf(real x)

{

return 2*log(x);

}

}

data

{

real d;

}

parameters

{

real<lower=0, upper=d> t;

}

model

{

t ~ lowertriangle(); // my custom prior distribution, described in functions block above

}

When I run it, I get a sample from t which seems correct; however, when I plot t vs the built-in variable lp__,

I get a skewed parabola, going up with t at the beginning but going deep down for the larger values its domain,

which is far from the expected t vs 2*log(t) plot.

Is is a bug? Or am I missing something in the way Stan is working here?

Thanks in advance for any help.

Patrick