Assume I have a Poisson distribution that draws the number $n$ of points to sample: $\mathcal{P}_{\lambda}(x)$. Then, I sample $n$ points from a uniform distribution $\mathcal{U}_{[0,4]}(x)$
However, in the end, I am only interested in the points in [0, 4/d], and I do not want to sample all the unnecessary points. So, my idea was to sample $\tilde{n} = \mathcal{P}_{\lambda/d}(x)$ points from $\mathcal{U}_{[0,4/d]}(x)$ or sample $n' = \mathcal{P}_{\lambda}(x)/d$ points from $\mathcal{U}_{[0,4/d]}(x)$.
Are the results equal? Can I do so?
I created a short Matlab example:
clc
clear all
close all
lambda_7 = 7;
num_trials = 10000;
r74 = 0;
for i = 1:num_trials
r7(i) = 0;
for m = 1:poissrnd(lambda_7)
if rand(1)*4 < 1
r7(i) = r7(i) + 1;
end
end
r74(i) = poissrnd(lambda_7/4.);
r7b(i) = round(poissrnd(lambda_7)/4.);
end
avg7 = sum(r7) / num_trials
avg74 = sum(r74) / num_trials
figure
hold on
h7 = histogram(r7)
h74 = histogram(r74)
It points out that both could yield the same distribution.
(Sorry for the bad title, feel free to make it more concise.)
Edit: Matlab code revised.
Your second option of sampling $n' = \mathcal{P}_{\lambda}(x)/d$ points from $\mathcal{U}_{[0,4/d]}(x)$ should not work. $n'$ will have the wrong distribution in general (and sometimes may not be an integer) and will not have the same distribution as $\tilde n$.
So instead you could choose $n$ from $\mathcal{P}_{\lambda}(x)$ and then $n'$ by choosing it from the correct distribution, which is binomial with parameters $n$ and $\frac1d$, and then sample that many points from $\mathcal{U}_{[0,4/d]}(x)$. This will not be faster than your method for $\tilde n$ but might be easier for some people to understand.