# 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 # 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 TransformedDistributionlooks like promising alternatives to Probability for continuous distributions.

If this desired function does not exist then my questions is: Define this function.

The OP considers the Uniform distribution over the unit disc

i.e. $$(X,Y)$$ have joint pdf $$f(x,y)$$: Then, the Marginal and Conditional functions from the mathStatica package for Mathematica do what you seek.

The marginal pdf of $$Y$$ is: The conditional pdf of $$Y$$ given $$X = x$$ is: • hahaha! +1 for being wise master user – Conor Cosnett Aug 5 at 16:07

Apparently Mathematica provides syntax for extracting conditional CDFs from a continuous joint distribution:

This syntax can be used as an intermediate stepping stone to deriving the desired conditional PDF.

dist = ProbabilityDistribution[Piecewise[{{1/\[Pi], 0 <= Sqrt[x^2 + y^2] <= 1}}], {x, -1,1}, {y, -1, 1}];
cdf = Probability[X <= x \[Conditioned] Y == y, {X, Y} \[Distributed] dist];
conditionalDensityFunction = PDF[ProbabilityDistribution[{"CDF", cdf}, {x, -1, 1}], x]  # update

The comments underneath this answer to a similar question suggests that we are still waiting for this functionality: • I think there's something not quite right about the resulting conditional density function. One gets 0 everywhere when $y=1$ and the area under the density is less that 1. Don't you want to use D[cdf, x] or conditionalDensityFunction = FullSimplify[ PDF[ProbabilityDistribution[{"CDF", cdf}, {x, -1, 1}, Assumptions -> -1 < y < 1], x]] for the conditional density? – JimB Aug 3 at 17:05
• yes, I think your right, I will try and fix it, or replace it with an alternative – Conor Cosnett Aug 3 at 19:48
• Not to make excuses for Mathematica but the domains get more complex, too, besides the form of the density function. So I can see how it might be difficult to have a general function the spits out conditional densities. – JimB Aug 3 at 20:15