if Yoda and Obi Wan needed special training to become force ghosts then how did Anakin manage to do it?

Although I don't believe it's canon any longer, I do believe I have the actual answer to your question. In the epilogue of Ryder Windham's The Rise and Fall of Darth Vader, just after Darth Vader dies at the end of Episode VI, Spoiler Although this seems a little far-fetched since it supposedly took Yoda, Obi-Wan, and Qui-Gon quite some time to master this technique. I've included the passage from the book below, in case you're curious.

Spoiler

So yeah, I really don't think this is canon anymore (I don't know if it ever was - the book was published by Scholastic Inc, so take that as you will). That said, this is the only definitive answer to this question that I've ever come across.

/r/StarWars Thread