`init_mean` argument not working as expected
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 207
- Forks
- 28
- Avg merge
- 7d 21h
- Merged PRs (30d)
- 1
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the nutpie.sample entry point and reproduce the issue with the provided Stan model and three init_mean values. Trace how init_mean is handled before sampling, then add or update tests that distinguish the initializations and verify the expected warning or failure for the invalid value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100