Law of total variance
The law of total variance is a fundamental result in probability theory that expresses the variance of a random variable Y in terms of its conditional variances and conditional means given another random variable X. Informally, it states that the overall variability of Y can be split into an “unexplained” component (the average of within-group variances) and an “explained” component (the variance of group means). Formally, if X and Y are random variables on the same probability space, and Y has finite variance, then: Var ( Y ) = E [ Var ( Y ∣ X ) ] + Var ( E [ Y ∣ X ] ) .