Generated random samples of dependent ratios The question is simple, however I am stuck:
I am trying to generate samples of ratios of "detections" vs "non-detections":
Say I counted 10 stars, and I could detect 8 stars. My detection ratio thus is 8/10.
Since this is a counting experiment, I would have naively assumed that both are Poisson variables and I can simply generate:
sample_classified = np.random.poisson(8, size=100)
sample_total      = np.random.poisson(10, size=100)

ratio = sample_classified/sample_total

this than can give me ratios that are greater than one, if the sample_classified > sample_total. That is however not logical since I can't have more classified stars as than there are in total.
The drawn samples should reflect that the ratio 8/10 is determined from an experiment, i.e. their histogram should peak at that value.
What is the correct PDF to sample from in that case?

I think I would do a sort of hierarchical model, like this:

*

*First, choose the denominator via a Poisson distribution:

array_length = 100
sample_total = np.random.poisson(10, size=array_length)



*Next, loop through sample_total and choose a binomially-distributed integer from $0$ to the total:

# Pre-allocate array for speed.
binomial_probability = 0.8
sample_classified = np.zeros(array_length, dtype=np.int64)
for i in range(array_length):
    limit = sample_total[i]
    sample_classified[i] = np.random.binomial(limit, binomial_probability)

This assumes a binomial distribution for the number of classified stars, once the Poisson total has been determined. Only you can tell us if that's a good assumption. But this code guarantees that, for each total, the number of classified stars will be less than or equal to the total.
