How to find out which distribution(sample) a number is coming from?

Solution 1:

Given $x$, we compare $P(D_1|x)$ and $P(D_2|x)$ and decide which has a higher value.

To compute these values though, some assumptions and prior knowledge are required.

From Bayes' rule, this is equivalent to comparing $P(D_1)P(x|D_1)$ and $P(D_2)P(x|D_2)$. We have to make assumption about $P(D_i)$.