I need two random numbers. The first one, u, is discrete and takes 70% of the time the value 0 and 30% of the time the value 1. The second one, v, is continuous and takes values uniformly inside [0, 1[.
Can I used only one random number, x, to generate u and v ? Such as:
u = 0 if x < 0.7 else 1 v = x / 0.7 if x < 0.7 else (x - 0.7) / 0.3
I'm wondering if this is correct and do not introduce any bias or artifact (correlation ?) between u and v because they are generated using the same x.
Also (it is more of a computer science question), but what about the floating point imprecisions implied by scaling x to get v ? Finally, is this can be extended if u takes more values (for example, 10% 0, 20% 1 and 70% 2). Thank you.