Var(X) = E[(X - mu)^2] (eq 3.19), cross-checked against the computational form E(X^2) - mu^2 (eq 3.34); their agreement is eq (3.35) and the square root is eq (3.40).
References
Morin, D. J. (2016). Probability: For the Enthusiastic Beginner. Createspace. Eqs (3.19), (3.34)-(3.35), (3.40), (3.59).
Examples
PmfVar(1:6, rep(1 / 6, 6))$variance
#> [1] 2.916667
