Now you're probably thinking, "They were spies who were sent to assassinate key targets and infiltrate lands disguised as peasants or in that cool navy black clothing. How could they 'beat' a samurai who was trained to fight head on?" Well since they didn't say who would win in a head on fight and that the person simply said "who is better?" The ninja would have the advantage. Now here me out first, a person's life span, even at that time didn't entirely consist of fighting. The average human needs to eat,rest,take a crap. A ninja (Depending on the skill level yet would have to be somewhat knowledgeable and trained) would learn how to take advantage in these intervals in conflict. A ninja could infiltrate a fort and poison the Samurai or assassinate him through other means. If the ninja is discovered well...Better hope he has a good escape.
Ninjas and samurais are like cousins. However ninjas realized earlier on that most of the more sophisticated missions need to be done in stealth..this is where the ninja excels and the samurai is at a disadvantage. Samurais will be better suited to fight a war in the more traditional way.
While the idea of ninjas are cool, (stealthy people who sneak around throwing ninja stars and wearing black) the portrayal of ninjas is not a very realistic one. Samurai's were real fighters who were very talented at what they did and wore very intricate and awesome looking suits of armor.