Cerium and its technologically relevant compounds are examples of anomalous mixed valency, originating from two competing oxidation states -itinerant Ce 3+ and localized Ce 4+ . Under applied stress, anomalous transitions are observed but not well understood. Here we treat mixed valency as an "alloy" involving two valences with competing and numerous site-occupancy configurations, and we use density functional theory with Hubbard U (i.e., DFT+U) to evaluate the effective valence and predict properties, including controlling valence by pseudo-ternary alloying. For Ce and its compounds, such as (Ce-La)2(Fe-Co)14B permanent magnets, we find a stable mixed-valent α-state near the spectroscopic value of νs = 3.53. Ce valency in compounds depends on its steric volume and local chemistry; for La doping, Ce-valency shifts towards γ-like Ce 3+ , as expected from steric volume; for Co doping, valency depends on local Ce-site chemistry and steric volume. Our approach captures the key origins of anomalous valency and site-preference chemistry in complex compounds.