Statistics and Probability for Data Science

Chapter 4
Joint Distributions and Dependence

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

4. Joint Distributions and Dependence

Introduction and Context

Many data-science questions concern more than one variable at a time. A retailer may study transaction value and customer age; a public-health researcher may examine exposure and disease status; a machine-learning engineer may investigate the joint behaviour of model errors and input characteristics. Analysing variables separately can conceal relationships that are essential for prediction, risk assessment, and decision-making. Joint distributions provide the mathematical framework for describing how two or more random variables behave together.

The ideas in this chapter extend the single-variable probability concepts introduced earlier. A marginal distribution describes one variable viewed in isolation, while a conditional distribution describes one variable given information about another. Covariance and correlation summarise certain forms of dependence, but they do not capture every important relationship. Conditional expectation, transformations, and mixture distributions provide more flexible tools for modelling and analysing multivariate data.

These concepts are central to statistical modelling. Regression, Bayesian inference, portfolio risk, classification, simulation, missing-data analysis, and probabilistic machine learning all rely on an understanding of joint and conditional behaviour. Equally important is knowing when a convenient summary, such as correlation, is insufficient or misleading.

Learning Objectives

After completing this chapter, the reader should be able to:

1. Define joint, marginal, and conditional distributions for discrete and continuous random variables.

2. Derive marginal distributions from joint distributions and calculate conditional probabilities or densities.

3. Explain independence and distinguish it from zero correlation.

4. Compute and interpret covariance, correlation, and conditional expectation.

5. Analyse transformations of random variables using suitable methods.

6. Explain mixtures and their effects on dependence and variability.

7. Identify limitations of correlation-based reasoning.

8. Apply these ideas to data-science and professional decision-making problems.

The Joint Distribution as a Description of Co-occurrence

Let X and Y be random variables defined on the same probability space. Their joint distribution describes probabilities associated with pairs of values occurring together. For discrete variables, the joint probability mass function (pmf) is

pX,Y(x,y) = P(X = x, Y = y).

It satisfies pX,Y(x,y) ≥ 0 and

Σx Σy pX,Y(x,y) = 1.

For continuous variables, the joint probability density function (pdf), fX,Y(x,y), is non-negative and satisfies

∫∫ fX,Y(x,y) dx dy = 1.

Probabilities are obtained by integrating over regions. For example,

P((X,Y) ∈ A) = ∬A fX,Y(x,y) dx dy.

A joint distribution contains more information than two separate distributions. Knowing that X is normally distributed and Y is normally distributed does not, by itself, determine how X and Y behave together. Different joint distributions can have the same marginal distributions but very different dependence structures.

A useful geometric interpretation is to regard (X,Y) as a random point in a plane. A joint density indicates where probability mass is concentrated. A narrow diagonal cloud suggests positive association, while an elongated cloud with negative slope suggests negative association. Curved or separated patterns may indicate dependence that a straight-line summary cannot represent.

Marginal Distributions

The marginal distribution of X is obtained by summing or integrating out Y. For discrete variables,

pX(x) = Σy pX,Y(x,y).

For continuous variables,

fX(x) = ∫ fX,Y(x,y)dy.

Similarly,

pY(y) = Σx pX,Y(x,y), fY(y) = ∫ fX,Y(x,y)dx.

The word marginal reflects the traditional practice of placing row and column totals in the margins of a probability table. Marginalisation is also fundamental in statistical computing: a variable that is not of immediate interest is integrated out while preserving uncertainty about the variable of interest.

Example: A Discrete Joint Distribution

Suppose X records the number of service requests received in an hour and Y records whether a response exceeds a specified time threshold. Consider the joint table:

Y = 0 Y = 1 Total

X = 0 0.30 0.05 0.35

X = 1 0.20 0.15 0.35

X = 2 0.05 0.25 0.30

Total 0.55 0.45 1.00

The marginal probability P(X=1) is 0.35, and P(Y=1) is 0.45. The probability that two or more requests occur and the response is delayed is P(X≥2,Y=1)=0.25. The table also suggests dependence: the conditional probability P(Y=1|X=2)=0.25/0.30=0.833, whereas P(Y=1)=0.45. Delays are more likely when the request count is two.

Conditional Distributions and the Logic of Information

A conditional distribution updates the distribution of one variable after the value or event involving another variable is known. For discrete variables,

P(Y=y|X=x) = pX,Y(x,y)/pX(x),

provided pX(x)>0. For continuous variables, the conditional density is

fY|X(y|x) = fX,Y(x,y)/fX(x),

provided fX(x)>0.

The joint distribution can be reconstructed from a marginal and a conditional distribution:

fX,Y(x,y) = fY|X(y|x)fX(x).

This factorisation is especially important in probabilistic modelling. It separates a baseline distribution for X from a model describing how Y changes when X changes. The alternative factorisation is fX,Y(x,y)=fX|Y(x|y)fY(y). Bayes’ theorem connects the two conditional directions:

fX|Y(x|y) = fY|X(y|x)fX(x)/fY(y).

Conditional probabilities must not be confused with joint probabilities. P(X=x,Y=y) concerns both events occurring together; P(Y=y|X=x) concerns the probability of Y after restricting attention to cases where X=x.

Independence

X and Y are independent if knowledge of one does not change the distribution of the other. For discrete variables,

pX,Y(x,y)=pX(x)pY(y)

for every x and y. For continuous variables,

fX,Y(x,y)=fX(x)fY(y)

almost everywhere.

Equivalent statements include P(Y∈B|X=x)=P(Y∈B) for relevant x and P(X∈A,Y∈B)=P(X∈A)P(Y∈B) for all measurable sets A and B. Independence is a strong condition. It implies zero covariance when the relevant moments exist, but zero covariance does not generally imply independence.

A common professional error is to infer independence from an absence of visible linear association. Independence concerns all aspects of the joint distribution, including nonlinear and tail behaviour.

Covariance, Correlation, and Dependence

Covariance measures the direction of joint linear variation:

Cov(X,Y)=E[(X−EX)(Y−EY)] = E[XY]−E[X]E[Y].

If large values of X tend to occur with large values of Y, covariance is typically positive. If large values of one tend to occur with small values of the other, it is typically negative. Covariance depends on measurement units: changing dollars to cents multiplies covariance by 100, while changing metres to centimetres affects it similarly.

The Pearson correlation coefficient standardises covariance:

ρX,Y = Cov(X,Y)/(σXσY),

provided both standard deviations are positive. It lies between −1 and 1. A value near 1 indicates strong positive linear association; a value near −1 indicates strong negative linear association; a value near 0 indicates little linear association.

Correlation is invariant to positive changes of scale and changes sign under a negative rescaling. It is therefore easier to compare across datasets than covariance. However, it remains a measure of linear association, not a complete measure of dependence.

Important Distinctions

If X and Y are independent, then Cov(X,Y)=0, assuming finite expectations and variances. The converse fails. For example, let X be uniformly distributed on [−1,1] and let Y=X². Y is completely determined by X, so the variables are dependent. Yet

E[X]=0,

E[XY]=E[X³]=0,

and therefore Cov(X,Y)=0.

The dependence is curved rather than linear. A scatterplot would reveal a U-shaped pattern, even though Pearson correlation is zero.

Correlation can also be distorted by outliers. A single unusual observation may substantially alter the means, standard deviations, and covariance. Restriction of range can reduce an observed correlation even when a relationship exists in the wider population. Aggregating data can produce a relationship different from the relationship within subgroups, a phenomenon associated with ecological bias and Simpson’s paradox.

Rank-based measures such as Spearman’s rho and Kendall’s tau can be useful when relationships are monotonic but not linear, or when variables are ordinal. They do not, however, automatically solve problems caused by confounding, selection, or non-monotonic dependence.

Conditional Expectation: Prediction with Partial Information

The conditional expectation of Y given X is the expected value of Y after X has been observed. For a discrete X,

E[Y|X=x] = Σy yP(Y=y|X=x).

For a continuous conditional density,

E[Y|X=x] = ∫ y fY|X(y|x)dy.

The expression E[Y|X] denotes a random variable: a function of X. It is the best mean-square predictor of Y based on X. More precisely, among all functions g(X), E[Y|X] minimises E[(Y−g(X))²]. This result explains why conditional expectation is central to regression and forecasting.

The law of total expectation states

E[Y] = E[E[Y|X]].

For variance, the law of total variance states

Var(Y)=E[Var(Y|X)] + Var(E[Y|X]).

The first term represents average variability remaining within groups defined by X. The second represents variability between conditional means. This decomposition is useful in hierarchical data, quality control, risk modelling, and analysis of variance.

Example: Conditional Risk

Suppose a loan applicant belongs to a risk group X, and Y is the eventual monetary loss. Even if the overall expected loss E[Y] is moderate, the conditional values E[Y|X=high] and E[Y|X=low] may differ substantially. A risk model that uses only the overall mean ignores information available from group membership. Conversely, if group membership is a proxy for a protected attribute, using it requires careful fairness and governance analysis.

Transformations of Random Variables

Data science frequently transforms variables: logarithms reduce skewness, ratios express rates, and principal components rotate coordinate systems. Probability theory must determine the distribution of transformed variables.

For a discrete transformation, probabilities are found by summing the probabilities of all original points that produce the transformed value. If U=g(X,Y), then

P(U=u)=Σ(x,y):g(x,y)=u pX,Y(x,y).

For continuous one-to-one transformations, let (U,V)=g(X,Y), with inverse (X,Y)=h(U,V). The change-of-variables formula is

fU,V(u,v)=fX,Y(x(u,v),y(u,v)) |J|,

where J is the determinant of the Jacobian matrix of the inverse transformation:

J = ∂(x,y)/∂(u,v).

The absolute value is required because densities describe non-negative probability volume.

Sum and Difference

If U=X+Y, deriving the distribution of U generally requires convolution. For continuous variables,

fU(u)=∫ fX,Y(x,u−x)dx.

If X and Y are independent, this becomes the familiar convolution of their marginal densities. Independence is therefore a simplifying assumption, not a requirement of the transformation method.

For U=X+Y and V=X−Y, the inverse is X=(U+V)/2 and Y=(U−V)/2. The Jacobian’s absolute determinant is 1/2, so the joint density of (U,V) is obtained by substituting these expressions and multiplying by 1/2.

Transformations can reveal structure that is hidden in the original scale. For instance, the logarithm converts multiplicative relationships into additive ones, while standardisation makes variables comparable in scale. Such transformations alter interpretation and can affect correlation, so they should be justified rather than applied mechanically.

Mixture Distributions and Hidden Groups

A mixture distribution arises when observations come from multiple subpopulations, but the subgroup label may be observed or unobserved. If Z is a latent group indicator with P(Z=k)=πk and conditional density fX|Z(x|k), then

fX(x)=Σk πk fX|Z(x|k).

The mean of a mixture is

E[X]=Σk πk E[X|Z=k],

and its variance is

Var(X)=E[Var(X|Z)] + Var(E[X|Z]).

A mixture may be multimodal, skewed, or heavy-tailed even when every component distribution is normal. In data science, Gaussian mixture models are used for clustering, density estimation, anomaly detection, and soft classification.

Mixtures also explain why aggregate correlations can be misleading. Suppose two groups each show a positive relationship between X and Y, but the group means are arranged so that the combined data show a negative relationship. The aggregate association then reflects both within-group association and between-group differences. This is one form of Simpson’s paradox.

A mixture is not the same as a single distribution with averaged parameters. If a population contains two groups with different means, the between-group component contributes to total variance. Ignoring that component can lead to underestimated uncertainty and inappropriate decisions.

An Illustrative Case Study: Predicting Customer Churn

Background

A subscription software company wants to identify customers at risk of cancelling. It has data on monthly usage X, customer-support contacts Y, contract type Z, and churn status. The analytics team initially reports that usage and support contacts have correlation close to zero.

Situation and Problem

Management interprets the near-zero correlation as evidence that usage and support needs are unrelated. It proposes excluding support contacts from the churn model. However, the data are a mixture of contract types, and the scatterplot appears to contain distinct groups.

Analysis

Within annual contracts, customers with high usage tend to contact support more frequently because they use advanced features. Within monthly contracts, high usage is associated with fewer support contacts because experienced users solve problems independently. When the groups are combined, the opposing slopes produce a weak overall correlation.

The team estimates conditional distributions rather than relying only on a single correlation. It examines P(churn=1|X,Y,Z), calculates group-specific conditional means, and compares the joint distribution of usage and support contacts by contract type. It also uses the law of total variance to distinguish variation within contract types from variation between them.

A logistic model is fitted with usage, support contacts, contract type, and an interaction between usage and contract type. A mixture-model diagnostic is used as an exploratory tool, not as proof that the population has exactly two natural clusters.

Approach and Outcome

The revised analysis shows that support contacts are informative after conditioning on contract type. The interaction indicates that the meaning of a support contact differs across customer groups. The company retains support history in the model but restricts its use to legitimate service-improvement purposes. Model performance is evaluated separately across contract types, and probability calibration is checked before operational deployment.

Learning Points

The case illustrates that a marginal correlation can conceal conditional dependence. Joint and conditional distributions provide a richer account of the data. Mixture structure and interactions should be investigated before variables are discarded. Finally, predictive usefulness does not by itself justify every possible use of a variable; governance and fairness remain part of the analysis.

Applications in Data Science and Professional Practice

Joint distributions underpin feature engineering, probabilistic graphical models, Bayesian networks, and simulation. In finance, the joint behaviour of asset returns is used for portfolio risk and stress testing. In healthcare, conditional distributions support diagnostic reasoning and treatment evaluation. In manufacturing, dependence between process variables can identify failure mechanisms. In marketing, customer attributes and responses are analysed jointly for segmentation and targeting.

In machine learning, a generative model estimates p(X,Y) or p(X|Y)p(Y), whereas a discriminative model focuses directly on p(Y|X). Missing-data methods require assumptions about the joint distribution of observed and unobserved variables. Monte Carlo simulation requires generating samples with the intended dependence structure; simulating each variable independently can severely understate joint risk.

Modern software makes calculation accessible, but it does not remove the need for statistical judgement. A covariance matrix may be estimated automatically, yet the analyst must assess sample size, outliers, missingness, non-stationarity, and whether a linear summary is appropriate. Visualising pairwise relationships, conditioning on important variables, and examining tails are essential complements to numerical summaries.

Limitations, Risks, and Common Mistakes

Several mistakes recur in applied work:

  • Treating correlation as evidence of causation. Association may arise from confounding, reverse causality, selection, or common time trends.
  • Treating zero correlation as independence. Nonlinear and tail dependence can remain.
  • Ignoring units and scale when interpreting covariance.
  • Using Pearson correlation automatically for ordinal, heavily skewed, or contaminated data.
  • Computing conditional probabilities with the wrong denominator.
  • Assuming that marginal normality implies joint normality. The dependence structure must also be specified.
  • Ignoring subgroup structure, producing misleading aggregate conclusions.
  • Estimating correlations from small samples without uncertainty intervals.
  • Treating a fitted mixture component as a real social or biological group without substantive evidence.
  • Confusing statistical prediction with a causal intervention.

Correlation matrices also have technical limitations. Pairwise estimates may be unstable, and a matrix assembled from different missing-data subsets may fail to be a valid positive-semidefinite covariance matrix. In high-dimensional settings, regularisation or dimensional reduction may be needed, but these methods introduce modelling choices that require validation.

Ethical and Governance Considerations

Dependence analysis can expose sensitive relationships involving health, income, location, or protected characteristics. Analysts should minimise unnecessary use of personal data, document data provenance, and control access to joint datasets. Conditional relationships can differ across demographic groups; reporting only aggregate results may hide unequal risks or service quality.

When a model uses conditional probabilities to make decisions, calibration and error rates should be examined across relevant groups. A correlation discovered in historical data may reflect past discrimination rather than a legitimate mechanism. Transparency about assumptions, uncertainty, and limitations is therefore part of professional statistical practice.

Emerging Directions and Best Practice

Dependence modelling is moving beyond Pearson correlation toward copulas, graphical models, nonlinear representation learning, and neural generative models. Copulas separate marginal behaviour from dependence, allowing analysts to combine non-normal marginals with flexible dependence structures. Vine copulas and normalising flows can model complex multivariate relationships, although they require substantial data and careful validation.

A sound workflow is to begin with the substantive question, inspect the data jointly, identify plausible subgroups and temporal structure, choose summaries appropriate to the measurement scale, and estimate uncertainty. Analysts should compare marginal, conditional, and joint views; test sensitivity to outliers and transformations; and validate conclusions on new data where possible. Interpretability and governance should be considered alongside predictive performance.

Chapter Summary

Joint distributions describe how random variables occur together. Marginal distributions are obtained by summing or integrating out variables, while conditional distributions update uncertainty using information about another variable. Independence factorises a joint distribution into marginals and implies zero covariance, but zero covariance does not imply independence.

Covariance measures unstandardised linear co-movement, and correlation standardises it to the interval [−1,1]. Neither captures all forms of dependence. Conditional expectation gives the best mean-square prediction based on available information and leads to the laws of total expectation and total variance. Transformations require summation, integration, convolution, or Jacobian methods. Mixture distributions represent heterogeneous populations and can create misleading aggregate associations. Effective data-science practice therefore combines mathematical summaries with visualisation, subgroup analysis, uncertainty assessment, domain knowledge, and ethical governance.

Key Terms

Joint distribution: The probability law describing two or more random variables together.

Joint pmf: The probability assigned to each combination of values of discrete variables.

Joint pdf: A density whose integrals over regions give probabilities for continuous variables.

Marginal distribution: The distribution of one variable obtained by summing or integrating out the others.

Conditional distribution: The distribution of one variable given information about another.

Independence: A relationship in which knowledge of one variable does not alter the distribution of another.

Covariance: The expected product of deviations of two variables from their means.

Correlation: Standardised covariance measuring linear association.

Conditional expectation: The expected value of a variable given observed information.

Law of total expectation: The identity E[Y]=E[E[Y|X]].

Law of total variance: The decomposition Var(Y)=E[Var(Y|X)]+Var(E[Y|X]).

Transformation: A new random variable created by applying a function to existing variables.

Jacobian: The determinant used to adjust density under a differentiable change of variables.

Convolution: The operation used to derive the distribution of a sum of random variables.

Mixture distribution: A distribution formed by combining component distributions with mixing probabilities.

Latent variable: An unobserved variable used to represent hidden structure.

Simpson’s paradox: A reversal or distortion of an association after data are aggregated across groups.

Nonlinear dependence: Dependence that is not adequately represented by a straight-line relationship.

Copula: A model separating marginal distributions from their dependence structure.

Review Questions

Short Answer Questions

1. How is a marginal density obtained from a joint density?

2. State the condition defining independence for two continuous random variables.

3. Why is covariance dependent on measurement units?

4. What does conditional expectation represent in prediction?

5. Distinguish a mixture distribution from a single distribution with averaged parameters.

Long Answer Questions

1. Explain the relationship among joint, marginal, and conditional distributions, including the relevant factorisations.

2. Discuss covariance and correlation, including their interpretation and limitations.

3. Derive and explain the laws of total expectation and total variance.

4. Describe the change-of-variables method for continuous random variables and explain the role of the Jacobian.

5. Explain how hidden subgroups can produce misleading aggregate associations, using Simpson’s paradox as a framework.

Analytical / Application Questions

1. Let X be uniformly distributed on [−1,1] and Y=X². Show that X and Y are dependent but uncorrelated. Explain why correlation fails in this example.

2. A bank observes that the overall correlation between income and loan default is weak. Propose an analysis using joint and conditional distributions that could reveal subgroup-specific risk.

3. A portfolio simulation generates each asset return independently, although historical data show substantial dependence during market downturns. Explain the likely risk consequences and propose a more appropriate modelling strategy.

22. Multiple Choice Questions with Answers

Question 1

For a continuous pair (X,Y), which expression gives the marginal density of X?

A. fX(x)=fX,Y(x,y)

B. fX(x)=∫ fX,Y(x,y)dy

C. fX(x)=∫ fY|X(y|x)dx

D. fX(x)=fY(y)fX,Y(x,y)

Correct Answer: B. fX(x)=∫ fX,Y(x,y)dy

Question 2

If X and Y are independent and have finite variances, which statement must hold?

A. Their correlation must equal 1

B. Their conditional means must be unequal

C. Their covariance must equal 0

D. Their joint distribution must be uniform

Correct Answer: C. Their covariance must equal 0

Question 3

Let Y=X² where X is symmetric about zero. Which conclusion is correct?

A. X and Y are independent

B. X and Y must have correlation 1

C. X and Y can be dependent but have zero covariance

D. Y must have a normal distribution

Correct Answer: C. X and Y can be dependent but have zero covariance

Question 4

What does E[Y|X] represent among all functions of X under squared-error loss?

A. The largest possible prediction error

B. The best mean-square predictor of Y

C. The marginal variance of Y

D. The probability that X equals Y

Correct Answer: B. The best mean-square predictor of Y

Question 5

Which identity correctly expresses the law of total variance?

A. Var(Y)=E[Y]+Var(X)

B. Var(Y)=E[Var(Y|X)]+Var(E[Y|X])

C. Var(Y)=Var(Y|X)−E[E[Y|X]]

D. Var(Y)=Cov(X,Y)²

Correct Answer: B. Var(Y)=E[Var(Y|X)]+Var(E[Y|X])

Question 6

When transforming a continuous random vector, why is the absolute Jacobian determinant used?

A. To ensure probabilities remain non-negative after volume changes

B. To force all variables to become independent

C. To remove the marginal densities

D. To guarantee a normal distribution

Correct Answer: A. To ensure probabilities remain non-negative after volume changes

Question 7

A weak aggregate correlation becomes strongly positive after conditioning on contract type. What is the most plausible explanation?

A. The variables cannot be jointly distributed

B. A subgroup or mixture structure was masking conditional dependence

C. Marginalisation always creates perfect correlation

D. Correlation is invariant to grouping

Correct Answer: B. A subgroup or mixture structure was masking conditional dependence

Question 8

Which statement about Pearson correlation is most accurate?

A. It detects every form of dependence

B. It is unaffected by extreme outliers

C. It measures standardised linear association

D. A value of zero proves independence

Correct Answer: C. It measures standardised linear association

Question 9

For a mixture distribution, total variance includes which components?

A. Only the variance within the first component

B. Average within-component variance and variance of component means

C. Only the variance of component probabilities

D. The covariance of unrelated variables only

Correct Answer: B. Average within-component variance and variance of component means

Question 10

A simulation generates two strongly dependent financial returns independently. What is a likely consequence?

A. Joint extreme losses may be underestimated

B. The marginal distributions become impossible

C. The returns necessarily become perfectly correlated

D. Conditional probabilities become irrelevant

Correct Answer: A. Joint extreme losses may be underestimated

Statistics and Probability for Data Science
Chapter 4 of 15