A random variable represents the uncertain outcome of a phenomenon. Its possible values may be discrete or continuous. For a three-sided die, write X for the roll and X=2 for the event that the observed outcome is 2; lowercase x stands for any possible outcome. A recorded roll is one outcome, not the random variable itself. section 2.1.1 section 2.3
A probability distribution assigns probability values to possible outcomes. For a discrete X, P(X=x) is the probability of one outcome, while P(X) denotes the distribution across all outcomes. Each probability is between zero and one, and the probabilities sum to one. Continuous variables use probability densities instead; those densities integrate to one. section 2.1.1 section 2.1.2
Listing 2.1 Implementing a discrete distribution table in pgmpy
from pgmpy.factors.discrete import DiscreteFactor
dist = DiscreteFactor(
variables=["X"], #1
cardinality=[3], #2
values=[.45, .30, .25], #3
state_names= {'X': ['1', '2', '3']} #4
)
print(dist)
A pgmpy DiscreteFactor specifies one variable, its three possible states, and their probabilities: 0.45, 0.30, and 0.25. section 2.1.2
From outcomes to an expectation
If X takes values 1, 2, and 3 with probabilities 0.45, 0.30, and 0.25, its expected value is E(X)=1(0.45)+2(0.30)+3(0.25)=1.8. This is a probability-weighted average, not a fourth possible die outcome. section 2.1.2 section 2.1.10
With multiple random variables, relationships matter as much as individual distributions. Independence means observing X does not change the probabilities for Y; conditional independence means this holds after accounting for another variable. Such constraints simplify joint distributions. In a causal model, variables can represent causes and effects, while parameters characterize their distributions. An ideal intervention fixes its target variable and changes distributions of causally downstream variables. section 2.1.9 section 7.3 section 2.1.6




