Context
In Mathematica one is able to directly calculate the marginal and conditional probability distributions of a discrete joint distribution (abstracting over the specific details) like so:
Represent joint distribution
dist = EmpiricalDistribution[{0.37,0.17, 0.14, 0.02, 0.24, 0.05} -> {
{0, 0}, {0, 1}
, {1, 0}, {1, 1}
, {2, 0}, {2, 1}
}];
get Marginal
marginal1= PDF[MarginalDistribution[dist, 1] , X]//Simplify
get Conditional
conditional = Probability[X == x \[Conditioned] Y ==y, {X,Y} \[Distributed] dist]//Simplify
Plot them
joint = PDF[dist, {x, y}];
marginal1 = PDF[MarginalDistribution[dist, 1], x];
marginal2 = PDF[MarginalDistribution[dist, 2], y];
conditional = Probability[X == x \[Conditioned] Y == y, {X, Y} \[Distributed] dist] // Simplify;
GraphicsGrid[{{DiscretePlot3D[joint, {x, 0, 2}, {y,0, 1}, ExtentSize -> Full, ViewPoint -> {2, -2, 2}, PlotLabel -> "P[X==x,Y==y]"],DiscretePlot3D[joint, {x, 0, 2}, {y, 0, 1},ExtentSize -> Full, ViewPoint -> {2, -2, 2},PlotLabel -> "P[X==x\[Conditioned]Y==y]"]},{DiscretePlot[marginal1, {x, 0, 2}, ExtentSize -> Full, PlotLabel -> "P[X==x]"],DiscretePlot[marginal2, {y, 0, 1},ExtentSize -> Full, PlotLabel -> "P[Y==y]"]}}]
Question:
I want to know how to calculate the conditional pdf of a continuous joint distribution, in a simple intuitive way like for the discrete case above.
Here is my attempt
represent Joint distribution
for instance: uniform distribution over the unit disk:
dist = ProbabilityDistribution[Piecewise[{{1/\[Pi], 0 <= Sqrt[x^2 + y^2] <= 1}}],{x, -1, 1}, {y, -1, 1}];
get Marginal
marginal1 = PDF[MarginalDistribution[dist, 1], x] //Simplify
get Conditional
?
What is an idiomatic way to obtain a conditional density function from a continuous joint distribution?
I know I could divide the Marginal into the Joint, but this does not seem very idiomatic. The master user should not have to waste cognitive power thinking about underlying math. Surely there is some built-in functionality to do this in Mathematica like there is for Marginal
? Preferably this functionality should take advantage of Conditional
.
Likelihood
and TransformedDistribution
looks like promising alternatives to Probability
for continuous distributions.
If this desired function does not exist then my questions is: Define this function.