-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
When running a Stan model, I tried using init_mean
parameter in sample
function. However, it's working as expected. An example illustrating my issue:
import nutpie
import numpy as np
code = """
data {
real mu;
}
parameters {
real<lower=0> x;
}
model {
x ~ normal(mu, 1);
}
"""
compiled = nutpie.compile_stan_model(code=code)
# Provide data
compiled = compiled.with_data(mu=10)
trace1 = nutpie.sample(compiled, tune=1, draws=11, chains=1, init_mean=np.array([-10]), seed=0)
trace2 = nutpie.sample(compiled, tune=1, draws=11, chains=1, init_mean=np.array([2]), seed=0)
trace3 = nutpie.sample(compiled, tune=1, draws=11, chains=1, init_mean=np.array([200]), seed=0)
print(trace1.posterior.x)
print(trace2.posterior.x)
print(trace3.posterior.x)
All traces lead to same sampling results.
<xarray.DataArray 'x' (chain: 1, draw: 11)> Size: 88B
array([[12.42946783, 12.42946783, 12.42946783, 12.42946783, 12.42946783,
12.42946783, 12.42946783, 12.42946783, 12.42946783, 12.42946783,
12.42946783]])
Coordinates:
* chain (chain) int64 8B 0
* draw (draw) int64 88B 0 1 2 3 4 5 6 7 8 9 10
In my understanding the output should be different depending on initialisation and I'd also expect first sampler to warn / fail due to incorrect initialisation. Could it be that init_mean
is not actually passed to the sampler?
Metadata
Metadata
Assignees
Labels
No labels