Shininess is determined by a calculation involving the Original Trainer's ID number and secret I Dnumber, as well as the Pokémon's personality value.

>Technically, the formula used is (TrainerID xor SecretID) xor (PersonalityValue>>16 xor (PersonalityValue mod 65536)); the latter two values represent the first 16 and last 16 bits of the 32-bit personality value, respectively. More detailed information can be found at the personality value article.

The above formula can result in a number from 0 to 65535. If the result is less than 8, then the Pokémon is Shiny. This gives an overall probability of 8/65536 or 1/8192, exactly the same as in Generation II.

This can be found here and is it possible to calculate when a shiny Pokemon is going to appear? If so, what are the calculations I need to do?