I've noticed that many droids in the Star Wars universe--specifically K-2SO and C-3PO--say a lot of things about chances of arbitrary things happening, like "Sir, the possibility of successfully navigating an asteroid field is approximately 3,720 to 1," or "You have a 97.6 percent chance of failure." I noticed while watching Rogue One hat some of these chances seem really hard to calculate, like whatever K-2SO said about Jyn betraying Cassian. How exactly are these chances determined?
The new Rogue One novelisation indicates that droids determine statistical probabilities by performing "mental simulations" of likely outcomes.
With one second left until total shutdown, K-2SO chose to mentally simulate an impossible scenario in which Cassian Andor escaped alive.
The simulation pleased him.