At the end of the story, Pi is met by two Japanese officials who interview him regarding the shipwreck. After they refuse to believe the story that has been told throughout the book, he tells them a second, far more gruesome tale. The implication is that the second story is true, the first being something of a psychological defense mechanism.
Pi creates a story involving animals being violent rather than have to process the reality of humans behaving like violent animals themselves. In this story, it would be Richard Parker who would have to commit a violent act in self-defense rather than Pi himself.
Pi's commitment to not just one religion, but three, gives him hope and comfort throughout his time on the lifeboat. It allows him a beautiful means of escapism and to make sense of a situation that was senseless.