In tennis, the better player doesn’t always win. Sometimes, she loses in straight sets.

Imagine if basketball, football or hockey games were decided by which team outscored the other in the most periods. Get outscored by 20 points in the first quarter, and it’s no problem, you just have to eke out the last three by a point each to take the game.

That’s sort of how tennis works. Win more sets than your opponent, and you win the match — even if your opponent played better throughout. These anomalous results happen rarely, but more often on grass, the surface of play at Wimbledon, which started this week.

This can be extremely frustrating for recreational players, and, in the heat of the moment, for pros. But given time to cool down, players whose paychecks depend on the tennis’s quirky scoring structure are at peace with its occasional oddities. Some even prefer things this way.

“I think that’s what’s great about our sport,” American pro Rajeev Ram said in an interview last week after losing in the last round of Wimbledon qualifying; he’ll play in the tournament’s doubles draw. “You have to finish the job. You can’t run out the clock.”

Ram was speaking from recent experience. Just the week before, he’d lived and died by this scoring quirk. Playing a grass-court event in Nottingham, England, Ram faced Tatsuma Ito in the quarterfinals. Ito dominated the match statistically. Ram won just 23 percent of points when Ito served. Ito won 30 percent of Ram’s service points. The ratio of return points won, or the dominance ratio (DR), was 1.33 for Ito. Typically a player with a DR greater than 1 wins, because of the symmetrical nature of the sport. Yet Ram managed to edge the second-set tiebreaker, 10-8, and win the match. He played what we might call a lottery match, and hit the jackpot.

The next day, Ram was a lot less lucky. He faced Samuel Groth, the Australian man who hit the fastest serve ever recorded — 163.4 mph. Ram outplayed Groth, winning 32 percent of return points to Groth’s 21 percent. Ram’s dominance ratio was 1.53, but he didn’t dominate. He earned seven break points, but couldn’t convert any. Groth didn’t get any chances to break. Both sets went to tiebreakers, and Groth won each one. Afterward, Ram tweeted, “Won 6 fewer points yesterday and won..won 5 more points today and lost. This is definitely not basketball.”

Groth, who won his Wimbledon qualifying match last week just as Ram was losing his, said afterward he’d make no apologies for his Nottingham win. “That’s just tennis,” Groth said. “It’s a bit of a cliché, but whoever is better on big points wins.” Groth added, “Grass can be a bit of a lottery.”

The data bears this out. Wacky outcomes like Ram’s pair of lottery matches happen more often at Wimbledon than at the other Grand Slams. Since 1991, 8.8 percent of completed Wimbledon men’s matches have been lottery matches, won by the player who was less successful at protecting his serve than his opponent. At the other three Grand Slam tournaments, that proportion ranged between 6.4 percent and 6.6 percent, according to data provided by Jeff Sackmann of Tennis Abstract. Over all men’s matches for which data is available, 7.5 percent end in this odd way.

Grass is more of a lottery because the ball’s low, skidding bounces reward big servers. They can stay competitive even while being outplayed simply by holding on to their service games and entering the sport’s version of soccer’s penalty kicks to decide draws in knockout matches: tiebreakers. And that’s especially true in the men’s game, which is more serve-dominated than women’s tennis.

Perhaps the most memorable run of lottery-match luck was Goran Ivanisevic’s at Wimbledon in 2001. The Croatian wild card won both his semifinal and final despite winning a lower percentage of return points than his opponent did in each of the five-set matches.

Already at this year’s Wimbledon tournament, men and women have won lottery sets and matches. Groth was better than Alexandr Dolgopolov in the second set of their match Monday, but lost that one and the other two to exit the singles tournament. Kimiko Date-Krumm, the oldest player in the draw at 43, won a higher percentage of return points than Ekaterina Makarova but lost in three sets. Leonardo Mayer and Dusan Lajovic won five-setters despite winning a lower percentage of return points than their opponents did.

In the fourth set of his match against Andrey Kuznetsov, Dan Evans won a greater percentage of return points. If Evans had won the set, he’d have extended the match to a fifth and deciding set. But instead Kuznetsov won it in a tiebreaker, 7-5. In Evans’s post-match press conference, a reporter asked, “There was nothing to choose between you really, was there?” The Briton responded, “No, just the scoreline and the sets.”

Even among all the grass-court lottery matches, Groth-Ram stands out. Among the more than 61,000 other straight-set wins for which data is available, just two times did the winner have a lower DR than Groth did.

The sport’s time-tested scoring system has many virtues, even if total fairness isn’t one of them. Its symmetry makes players alternate the deuce and advantage sides, switch sides of the net, rotate serving and returning. It guarantees that a player trailing by a big margin gets all the time it takes to stage a comeback, provided she performs well enough to earn that time. It keeps matches that are lopsided short, and lets close matches take all the time they need.

“It’s the beauty of the sport,” Denis Kudla said last week on the lawns of the Bank of England Sports Centre, just after clinching a spot in Wimbeldon’s main draw. “At the end of the day, whoever wins was the better player.” That maxim applied, in his mind, to a match he still remembered from three years earlier, when he beat Ivo Karlovic — on grass, of course — in a lottery match. “Sometimes these stats are funny,” Kudla, a 21-year-old American, said. “It’s cool when you do win less points, and do win.”

Being on the other end of one of these matches is less cool. Ante Pavic, at that same Nottingham tournament earlier this month, was in control of his second-round match against Miloslav Mecir, leading 6-3, 5-3. Mecir turned around the match, if not his level of play, beating Pavic despite winning just 29 percent of return points to Pavic’s 36 percent. “I wanted to break all the rackets,” Pavic recalled. “That’s how angry I felt.” Luckily he spared three of his sticks, which he used to qualify for Wimbledon, where he won his first-round match Tuesday.

Benjamin Becker has lost a dozen lottery matches in his pro career. Yet the 33-year-old German doesn’t mind the possibility of such bad luck. “You have just to deal with it,” Becker said in an interview Monday after winning his first-round match at Wimbledon. “It doesn’t bother me. It makes tennis interesting.”