Hi folks – loving numpyro so far and the flexibility it offers with the various samplers. I came over from Stan, and I needed an alternative way of sampling from a combination of discrete and continuous probability spaces.

I’ve been working with a probability function which involves a copula factor which (as far as know isn’t an inbuilt distribution in NumPyro, and following a post in the forum I was able to add this component to the model function using `numpyro.factor`

.

My general question is – what is formally the output of a model function you provide to a kernel/MCMC sampler? Is it simply a prior/posterior (depending whether you pass in data or not) which is sampled from by the method of your choice?

The reason I ask is due to a bit of confusion between the specification of parameters in the joint. In the `numpyro.sample()`

docs, it simply claims that it `Returns a random sample from the stochastic function fn.`

To me this is not necessarily the same thing as adding a component to the log likelihood, as it claims to return a random MC sample from the distribution, *not* necessarily add it to a total log likelihood across the `model`

function. The `numpyro.factor()`

statement on the other hand appears to address this query directly to add arbitrary log probability factor to a probabilistic model. This appears to serve what I was interested in, I don’t think you can “instantialise” parameters in Numpyro without using a `sample()`

or `deterministic()`

command (unlike in Stan where you do so in the `parameters`

block).

So to summarise: what does the `sample`

function do within a model function? Does it simply instantiate a parameter and allow you to add a prior to the posterior you’ll sample with, or does it take draws from a MC sample directly rather than MCMC (in Stan terminology, the difference between a `normal()`

vs `normal_rng()`

function). If the former, then what is the difference between `sample()`

and `factor()`

apart from the fact that `sample`

allows you to use pre-built distributions from Numpyro? Is there a way to, for example, add a custom term to the posterior without initialising parameters in the `sample`

or `deterministic`

manner? Or would I need to initialise the parameters with unbounded uniform priors using sample *before* adding them to the `factor()`

command?