To be technically accurate, loot is generated the instant the mob spawns. There's a blue post about it on the forums... (see below) What it means, is that when you're farming, and someone ninjas a mob and gets the pet you're farming for... yes, they STOLE it from you. If you'd killed that mob, the pet would have dropped for you.
Originally Posted by Drysc (Blue Tracker)
Loot is generated upon creation. As soon as you step into an instance, or a mob is created in the world, the loot that's going to drop has already been determined.
is it based on some attribute of the players in the raid, or the raid leader?
Heh, no. I believe it uses a time stamp to seed the generator. So, there's nothing you can influence within the game that would alter or coerce the generator.
Does it mean that killing the same boss at the exact same time each week will get players the same loot everytime ?
No, the time it uses to seed would have no real implication into the final outcome of what loot its given. On a long enough generation table, you may see some type of pattern based purely on a random generators inability to truly be random. But we're talking about astronomical numbers, something ridiculous like hundreds of billions of generations. Nothing you would or could see a pattern in during your time playing the game.
What you're seeing is pure and basic laws of probability. Have a few thousand people roll a pair of dice and you're bound to see hundreds of people able to roll snake-eyes 10 times in a row. (not that dice are truly random either)