2
$\begingroup$

I want to draw a random sample from a known joint distribution. what I have now is the number of people in each age and income bracket (as shown in the example below):0.12 0.42 0.06 16 0.08 0.28 0.04

                   income $1-10,000    income $10,001-20,000
15-20 years old      0.12                      0.08
21-25 years old      0.42                      0.28
26-30 years old      0.06                      0.04

Using this I will get the joint distribution of income and age. But I am not sure where to go from here in terms of drawing samples.

Any thoughts are appreciated. My knowledge in statistics is quite limited...

$\endgroup$
4
  • $\begingroup$ This might answer your question. $\endgroup$ Commented Nov 8, 2016 at 15:39
  • $\begingroup$ This is not an empirical joint distribution--it is merely a summary of data. In what way do you hope to use it to infer or represent a distribution? $\endgroup$
    – whuber
    Commented Nov 8, 2016 at 15:41
  • $\begingroup$ After the edit it is still just a data summary. If by "joint distribution" you mean the discrete distribution for the six groups you have shown, then sample it as you would any discrete distribution. But if you want to sample from some hypothetical underlying distribution that gave rise to the data shown here, then you must make some strong assumptions about that distribution, fit it to the data, and then proceed to sample. $\endgroup$
    – whuber
    Commented Nov 8, 2016 at 16:44
  • $\begingroup$ I see. Let me try to sample a discrete distribution first. Thanks! $\endgroup$
    – whyq
    Commented Nov 8, 2016 at 16:48

1 Answer 1

3
$\begingroup$

If you want to sample (Age,Income) pairs, use any old sampling method directly on your joint distribution. Using numpy:

dist = [(("15-20 yr", "$1-10000"), 0.12), (("15-20 yr", "$10000-20000"), 0.08), ...]
num_of_samples = 10 # choose any size you want here
samples_i = numpy.random.choice(len(dist), size=num_of_samples, p=[x[1] for x in dist])
samples = [dist[x][0] for x in samples_i]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.