What determines the CP of a transformed Ditto?
It appears that as far as CP is concerned, Ditto simply takes on the base attack, stamina and defense stats of the Pokémon that it transforms into. These values, along with the Ditto's individual values, are plugged into the CP formula.
When it comes to HP, more research is required. Other sources are reporting that the HP stays the same, but I have not tested that aspect.
If the Ditto is at the same level as the Pokémon that it transforms into, it should have similar CP. A max level 100% Ditto, should have higher or the same CP as the Pokémon it transforms into.
So the transformed ditto CP formula looks like this:
Ditto_transformed_CP = Floor(((transformed_pokemon_base_attack + ditto_attack_iv)
* (transformed_pokemon_base_defense + ditto_defense_iv)^0.5
* (transformed_pokemon_base_stamina + ditto_stamina_iv)^0.5
* (ditto_level_multiplier)^2) / 10)
Testing
Test 1
I used a level 10.5 Ditto with 4/11/8 IVs against a Jolteon in a gym, and the Ditto CP changed to 756.
Ditto_transformed_CP = Floor(((232+4) * (201+11)^0.5 * (130+8)^0.5 * (0.432926413)^2)/10)
Ditto_transformed_CP = Floor((236 * (212)^0.5 * (138)^0.5 * 0.18742527967914354769) / 10)
Ditto_transformed_CP = Floor((236 * 14.56021978 * 11.74734012 * 0.1874252797) / 10)
Ditto_transformed_CP = Floor((7565.674354) / 10)
Ditto_transformed_CP = Floor(756.5674354)
Ditto_transformed_CP = 756
Test 2
I used a level 26 13/4/8 IV Ditto against a Tauros, and the CP changed to 1744.
Ditto_transformed_CP = Floor(((198+13) * (197+4)^0.5 * (150+8)^0.5 * (0.68116492)^2)/10)
Ditto_transformed_CP = Floor((211 * (201)^0.5 * (158)^0.5 * 0.4639856482) / 10)
Ditto_transformed_CP = Floor((211 * 14.17744688 * 12.56980509 * 0.4639856482) / 10)
Ditto_transformed_CP = Floor(17446.71131 / 10)
Ditto_transformed_CP = Floor(1744.671131)
Ditto_transformed_CP = 1744
Here is the breakdown of Ditto.
Ditto as a defender can be terrible if the attacker uses a Magikarp first.. but if they don't pay attention it could make them struggle a little bit.
As far as attacking, the IV's for attack and defense are copied from the pokemon you transform to, but the health/stamina is not. With that being said, transforming into a chansey/snorlax may not be the best pick as they both don't have very strong attacks. I recommend if needed to use a Ditto, use it on legendaries when they come out, or a pokemon with high attack like a Dragonite. The CP that the ditto gets is based on the current ditto level and the attack/defense stats on the pokemon you transform into. For any pokemon with high stamina ditto will always be much weaker, but for strong attacking pokemon with lower stamina, ditto may be the smarter choice especially if you can't max a dragonite due to not being able to find enough dratini's.
Ditto in the wild: Ditto has appeared as a magikarp, pidgey, rattata, and a zubat. The basic catch rate for all those are 40% or a little higher, while the ditto is 16%. So if you see one breaking out of pokeballs relentlessly, it may be a ditto or just shitty luck.
And a 100% ditto would not have equal or higher CP than what transforming into due to the stamina doesn't transfer over. Most pokemon in gyms you will find aren't maxed for their level, so it just may be the case that your ditto is a higher level than what your attacking.
Also, when transforming a ditto to another pokemon, you can still dodge the first two attacks even while transforming.
so from what I've experimented with, Ditto appears to have a CP multiplier. As far as I have tested, for dragonite, it is about a 5.1 multiplier. Lapras is a little lower. My 344 Ditto turned into a 1752 dragonite, while my 196 ditto turned into a 1001 dragonite. For lapras, my 344 turned to just over 1400 lapras, while my 196 turned into an 800 lapras, which leads me to believe that it is around 4 times multiplier for lapras. It did not matter which dragonite I used to fight the ditto, as it stayed the same CP for my 2160 dragonite and my 1500 dragonite.