Hi,

I’m trying to help a fellow physicist with a model and I think Stan could do the job. I don’t believe the details are required to discuss the modeling process, so I’ll keep it abstract. It has to do with quantum computing.

The group is trying to build a chain of 1s and 0s, but occasionally an error occurs, and we observe two identical consecutive numbers (i.e. two 1s or two 0s). The goal is to evaluate how many errors occur in this experimental setup, and what distribution the number of errors follows. On top of that, we need to account for measurement errors: . there is an (exactly known) chance of measuring a 1 where there is a 0 and vice-versa.

My intuition would be to use a multinomial distribution, where each event corresponds to a specific number of errors. The last event would be “more than N errors”. This produces discrete transformed parameters which then need to be transformed again because of measurement errors. But Stan doesn’t give me a straightforward way of dealing with discrete parameters.

I am contemplating two options:

- Write a new distribution for the multinomial + measurement error process – hmm, might be a lot of work to determine that analytically.
- Simulate data from the experiment data to “correct” for the measurement error and then fit the Stan model (which would be a simple multinomial) to the “corrected” data - which feels like a risky hack.

Maybe Stan isn’t the right tool for this problem? I think a Gibbs sampler might work, though I hear discrete parameters are tricky.

Thank you for your help!