I am trying to understand how to specify priors for variables that are subject to a constraint transform.

In particular, what I really want is to impose a U(0,\infty) prior on a variable.

My understanding is that when I specify

```
parameters {
real<lower=0> C;
}
```

this transforms to a new variable which is effectively \ln C, which has Jacobian dC/d\ln C=C=\exp(\ln C) and (*if I don’t explicitly give a prior to C in the model block*) effectively imposes the unconstrained prior \ln C\sim U(-\infty,+\infty) (i.e., P(C)\propto1/C. First, is this correct?

If so, then, second, it seems that I have two choices to impose my desired prior. I could pick a suitably large value of `Cmax`

and then use

```
model {
C ~ uniform(0,Cmax);
}
```

In practice, this is fine, since there is [almost?] always enough information to find a good `Cmax`

.

**Erratum**: I am pretty sure the following is incorrect – see below.

However, it occurs to me that I should be able to get the actual prior that I want by just “removing” the Jacobian of the constraint transform (and imposing no other prior on

`C`

):`model { target += -log(C); // note the minus sign }`

However, when I’ve tried this, the sampling hasn’t gone very well. Am I missing something?

**Update**: it now seems clear that I’ve got a sign error in the above. I really should be doing

```
model {
target += log(C); // note the plus sign!
}
```

in order to actually impose the Jacobian transformation to Uniform.

Thanks, @Funko_Unko for inadvertently helping me figure this out. It would still be good to get more knowledgeable input to confirm whether this is the right thing to do (or otherwise).

**Update 2** not sure this is right. See below.