The sampling without replacement
You can do it this way but it is a bit clumsy:
For $ \left | x2-x1 \right |=0$
Probability[x == 2 || y == 2 || z == 2, {x, y, z} \[Distributed]
MultivariateHypergeometricDistribution[2, {3, 3, 4}]]
For $ \left | x2-x1 \right |=1$
Probability[(x == 1 && y == 1) || (y == 1 && z == 1), {x, y, z}
\[Distributed]MultivariateHypergeometricDistribution[2, {3, 3, 4}]]
For $ \left | x2-x1 \right |=2$
Probability[(x == 1 && z == 1), {x, y, z}
\[Distributed]MultivariateHypergeometricDistribution[2, {3, 3, 4}]]
I am a bit late but another way to use MultivariateHypergeometricDistribution
:
md = MultivariateHypergeometricDistribution[2, {3, 3, 4}];
f[{___, 2, ___}] := 0
f[{1, 0, 1}] := 2
f[{___, 1, 1, ___}] := 1
td = TransformedDistribution[
f[{x, y, z}], {x, y, z} \[Distributed] md];
res = Probability[x == #, x \[Distributed] td] & /@ Range[0, 2]
Histogram[RandomVariate[td, 10000], Automatic, "PDF",
Epilog -> {Red, PointSize[0.02],
Point[MapIndexed[{#2[[1]] - 1/2, #1} &, res]]}]
Amplifying on answer by @bobbym
p[x_] = Piecewise[{Probability[#[[1]], {x, y, z} \[Distributed]
MultivariateHypergeometricDistribution[2, {3, 3, 4}]],
x == #[[2]]} & /@
{{x == 2 || y == 2 || z == 2, 0},
{(x == 1 && y == 1) || (y == 1 && z == 1), 1},
{x == 1 && z == 1, 2}}]
The distribution for |x1-x2|
is then
dist = ProbabilityDistribution[p[x], {x, 0, 2, 1}];
This distribution can be used like any other distribution
PDF[dist, x] // Simplify
CDF[dist, x]
Mean[dist]
(* 1 *)
Variance[dist]
(* 8/15 *)
SeedRandom[1]
RandomVariate[dist, 10]
(* {2, 0, 2, 0, 0, 0, 1, 0, 1, 1} *)