converting a known proportion to estimate probability per day I need some help understanding how to calculate the rate of occurrence per day or probability per day. If we know that almost 5% of the patients develop an infection in general, how can we use this information to estimate the rate of occurrence or probability per day?
Assuming I have N number of patient per day and I want to randomly convert some of them to infected based on given probability p. The way I am doing is that I am calling the below function per day and in this function, I am looping over all the patients and for every patient, I am doing a Bernoulli trial with the probability p to see if patient got infected or not. I am using Python.
trial = self.get_bernoulli_trial(p) 

def get_bernoulli_trial(self, p):
        return np.random.binomial(1, p)

If trial returns 1, I make that patient infected otherwise do nothing.
So the question is, is this a right way of doing this and how to estimate p per day for Bernoulli trial from the knowledge that 5% patients on average develop infection. If I use p = 0.05, would that be correct?
Any help will be appreciated.
 A: With your description, and code, you seem to assume that the infections are independent Bernoulli trials with same probability of infection $p$. In such case, since they are independent, it does not matter if you group them in days, or look at the global incidence, the probability remains the same. For each of the patients, independently, it is $p=0.05$ by definition.
Of course, this does not (and probably isn't) a realistic assumption. I guess that it could be possible that such events are clustered at time, for example, if there is an influenza outbrake, the probability of observing such patient gets large, but few months later it gets much smaller. However, to estimate such changes over time, you would need to know much more details, and have adequate temporal data. You cannot de-aggregate the single total number to learn about such variability.
A: $Binom(1, p)$ is not an appropriate function to use for generation, as the samples are drawn without replacement from a fixed pool of patients.
If you know that 5% of however many patients you have will be infected and you are interested in simulating whether any individual patient gets sick, you can use
$$p(sick) = Hypergeom(Total\ patients,Expected\ sick,Already\ added)$$
as the Bernoulli probability where $Expected$ is a sample from $Binom(Total, p)$ (where p=0.05 in this case), and $Added$ is the number of patients you rolled for so far plus one (you'd need to keep track of every patient that rolled a success as you set them as infected).
So for example, if the first patient out of 100 would use $Hypergeom(100, 5, 1)$, the second $Hypergeom(100, 5, 2)$ and so forth.
If you're not quite certain of the fraction, you can go one further back, and draw the $p$ in Binominal from a Beta distribution with the count of the infected patients and total patient count as parameters.
