Rstan : Could the output of the stan model (each post warmup iteration draws) be different between linux and windows?

Hi everyone,

I compiled the same .stan file on an Ubuntu 22.04.2 LTS linux computer server and on my Windows 11 computer. Then, on both hardware, I did the sampling() on the exact same data with the same argument seed = but the extracted post warmup estimations were different.
I tried to run the sampling with warmup = 0 and the chains initial values seemed to be the same.

The R version on my Windows computed is 4.1.3, and the R version on Ubuntu is 4.2.3.
For both OS the stan version is rstan_2.21.3

Was that expected ?

Thank you in advance

Luana

Hi @Luana, welcome to the Stan forums. Yes, what you’re seeing is possible because of issues with floating point arithmetic. There can be differences in the precision of different operations on different systems. In order to get the same exact numbers from Stan many things need to be true, which are described here:

When you see differences between Linux and Windows is it just that the individual posterior samples are slightly different or do you get different inferences? If sampling goes smoothly you can get slightly different individual samples with different systems, but the things that matter the most like posterior means, intervals, etc., should be very similar. In other words, for a well-behaved model the exact numbers might not be reproducible on different systems, but the inferences should be the same (up to noise).

Thank you @jonah for responding so quickly !

That’s exacly it. Estimations are very similar but not exactly the same, especially the means. I noticed because I use the whole posterior distributions and they can be slightly different.

Thank you for providing this link

1 Like