As a part of a bigger model, I need to have couple of lines of code that could be implementing the Paralazable system model for me.
The whole model is on a detector. This detector could record signals based on the elements that are arriving. The detectors have this inefficiency that it could lose its sensitivity for a certain amount of time after one element hits it.
In Paralyzable models the detector will be dead when an element hits it, even if it did not detect it. It means that certain number that we have as the dead time, could be changed if another element hit the detector in that time and it will add another dead time to that.
There is this link that you could read a little more about this topic: Dead time
I have made a random Poisson sample using numpy as something that could have the same behavior as the source (The source is making the elements based on Poisson distribution), then due to the fact that the detector could only detect one element at a time, we need to replace all the values more than one with one.
Then the last step is the main part that is actually applying the Paralzable dead time effect, which will remove the values with the dead time distance of the detected values.
import numpy as np
np.random.seed(2)
random_set = np.random.poisson(lam=1, size = 500) #The source is making the elements with Poisson distribution
#lam could be any other value
d = 2 #dead time, could be any other integers
#Saturation effect
#detector could not detect more than one elements at a time
random_set[random_set>1] = 1
index = 1
#Paralyzable dead time effect
for i in range(1, (random_set.shape[0])):
for j in range(index, index + d+1):
if random_set[j]==1:
index = j
random_set[j]=0
It does not make any errors but it is certainly not doing what I am looking for. Is there a fast way to make it work?
Thanks.