StanSample.jl icon indicating copy to clipboard operation
StanSample.jl copied to clipboard

`stan_sample` defaults depend on state of `SampleModel` (as potentially modified by previous `stan_sample` calls)

Open nsiccha opened this issue 3 months ago • 0 comments

I've found that behaviour confusing, as it's also not documented "anywhere" (where it's immediately obvious to the user).

Example code:

sm = Stan.SampleModel(...)
# This runs with engaged=true
Stan.stan_sample(sm; data, num_chains=1) |> display
Stan.stan_sample(sm; data, num_chains=1, engaged=false)
# This runs with engaged=false
Stan.stan_sample(sm; data, num_chains=1) |> display

Output (note engaged=true in the first line and engaged=false in the second line).

Process(`/tmp/jl_K1HcGM/nc_eight_schools_no_gq method=sample adapt engaged=true algorithm=hmc id=1 data file=/tmp/jl_K1HcGM/nc_eight_schools_no_gq_data_1.json output file=/tmp/jl_K1HcGM/nc_eight_schools_no_gq_chain_1.csv`, ProcessExited(0))
Process(`/tmp/jl_K1HcGM/nc_eight_schools_no_gq method=sample adapt engaged=false algorithm=hmc id=1 data file=/tmp/jl_K1HcGM/nc_eight_schools_no_gq_data_1.json output file=/tmp/jl_K1HcGM/nc_eight_schools_no_gq_chain_1.csv`, ProcessExited(0))

nsiccha avatar Nov 14 '25 09:11 nsiccha