I'd like to model the behavior of photodiodes, the input is like data bits (0 & 1) where each bit is represented maybe with 100 samples / bit and the bit rate is $B$ bits/sec with period $T_{bit}=\frac{1}{B}$, each sample represents the input optical power.

The required is to generate a time-domain shot noise for input signal based on the well-known shot (Poisson) noise variance $\sigma^2_{I_{shot}}=2qI_{0}\Delta f$, $I_{0}$ is the output current based on the input power via the relation $I_{0}=RP_{in}$ , $R$ is a constant and $\Delta f$ is the noise BW. The input is based on random bits with zero value for 0 bits and $I_0$ value for 1 bits, how to make the noise signal dependent based on the current bit using python? I have thought of a moving average filter that finds the average value for a window $T_{avg}$ but not sure how to relate $T_{avg}$ to $T_{bit}$, and accordingly add the shot noise based on the found average or just add the noise for each simulation sample per bit, is that correct? Is their an easier or a more correct way to do it?

  • $\begingroup$ that is an unusual application of shot noise levels, using 0 variance for values of binary "0". It's pretty unlike what you find usually in detectors. Are you sure you want this? $\endgroup$ Oct 15, 2023 at 11:09
  • $\begingroup$ Can you tell me what is wrong in this description? especially for detectors indeed. ? $\endgroup$ Oct 15, 2023 at 19:56
  • $\begingroup$ Thanks for the edit! But it confirms my answere $\endgroup$ Oct 16, 2023 at 21:17

1 Answer 1


You have two simple cases:

  1. Input is 0: then $\sigma^2_{I_{\text{shot}}} =0$, which means it is a constant value. So, in Python, that just means you set the result to = constant, for some value of constant that fits the rest of your needs (variance can't tell us anything about expectations, but =0 might be a good start?)
  2. Input is 1: then $\sigma^2_{I_{\text{shot}}}=2qI_0\Delta f$; I don't know what $q$ or $\Delta f$ are, but they must be constants in this context, so essentially, you get shot noise of some constant variance $v^2=2qI_0\Delta f$.

How to generate Poisson-distributed numbers is well-covered in Literature, including Wikipedia, so if you want to understand how it's generated, that's easily researchable. If you want to just to use someone else's code to generate it, well, you can't have looked very far: The popular scipy package contains a poisson generator in its scipy.stats module. It's documented here; just use poisson.rvs with your calculated variance $v^2$ as rate (for Poisson distributions, there's only one parameter, and that's rate, and variance happens to be the rate).

Regarding your update to your question:

The fact that there's "bit periods" underlying doesn't matter to the process – you have sample durations during which you either have variance 0, or the specified variance $v^2$. The fact that your process is poisson says exactly that: the moments of your count solely depend on the duration of your observation, not on what happens elsewhen.

So, your averaging is definitely mislead. I really don't know why you should do that – you have all the tools laid out for you:

  1. You know the distribution, Poisson
  2. You know the observation length, $T_{bit}/100$
  3. You know the rate, because that is identical to variance

So, all you need to do is draw a random number that's Poisson-distributed with the specified rate. That's it.

  • $\begingroup$ q is a charge constant and $\Delta F$ is the BW of integration of the PSD (which is white), my confusion is, shot noise is based on some variation of arrival of events (charges in my case) over some interval. It is not clear to me how to relate this averaging interval to the bit interval. $\endgroup$ Oct 15, 2023 at 19:53
  • $\begingroup$ In other words, does the noise changes abruptly and instantaneously from high value (at bit-1) to zero (bit-0) $\endgroup$ Oct 15, 2023 at 19:54
  • $\begingroup$ it's not clear where your "bit interval" comes from. Does that have physically anything to do with the process you're observing? I get the feeling you're mixing quite a few things here. Please clearly write down, in your question, what you're actually measuring / modelling. $\endgroup$ Oct 15, 2023 at 20:55
  • $\begingroup$ I am trying to model the noise added by a photodetector, at which its noise is shot noise, the input is the optical power (in the form of bits 1 & 0 , where each bit period is Tbit", how to generate the time-domain output with the added noise based on an input array of bits (that is oversampled, like I represent each bit by 100s sample for example). $\endgroup$ Oct 15, 2023 at 23:17
  • $\begingroup$ As said, please add this to your question, not just as a comment. Tbit is a unit of information, not of time, and a bit period is time. Do you perhaps mean 1/THz = 1 picosecond (ps)? I ask for multiple reasons, first of all because you really need to be very stringent with your notation here, secondly because it's really not clear what you mean - in the Tbit/s regime, we don't do simple on/off keying, for physical and efficiency reasons, and thirdly, because it's fundamentally difficult to impossible to oversample 1 THz hundredfold. And lastly, and most importantly, in this regime, quantum... $\endgroup$ Oct 15, 2023 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.