Here’s a scenario you’ve probably confronted if you live in a city and you use a ride-hailing app like Uber: It’s the end of the night. You’re tired. You open up the app, ready to slide comfortably into the back of a black sedan, when suddenly…you’re hit with 2.1x pricing.

Seriously?” you say to yourself. “Is it worth it?”

Uber’s “surge pricing” model, which people love to hate, is really just simple economics: The app calculates an increased demand for taxis, and increases the rate in order to attract more supply in the form of drivers. But the actual calculation is far from simple.

Uber employs a whole roster of data scientists to figure out exactly how much customers are willing to spend. They have found, for instance, that you’re more likely to accept surge pricing if your phone is low on battery. They’ve also found another unique insight: That customers, on average, are more willing to accept surge pricing if the rate is not rounded off to a whole number. For instance, Uber sees a big drop-off in usage when surge pricing goes from 1.9x to 2.0x. Why?

“When you tell someone your trip is going to be two times more than it usually costs, they think, ‘Well, that’s capricious and unfair…” Keith Chen, Uber’s former head of economic research, told NPR earlier this year. “Whereas if you say, ‘Oh, your trip is going to be 2.1 times more than it normally does, [consumers think] ‘Wow, there must be some smart algorithm in the background here that’s at work.’ It doesn’t seem quite as unfair.”

And yet, while a specific surge rate of 1.9 or 2.1 might not seem quite as unreasonable, any rational consumer is still going to be ticked off. “Any time prices become unpredictable and uncertain and opaque, consumers do not like it,” says Utpal Dholakia, a marketing professor at Rice University, whose research focuses on studying financial decisions by consumers.

A few months back, Dholakia was stuck in exactly this situation. He was traveling in London for a conference and staying in an Airbnb. He was a little bit late to his next meeting, so instead of taking the Underground, he pulled open his Uber app and was hit with a 1.9x surge.

Now, Dholakia is one of the county’s foremost experts on dynamic pricing models and how it affects consumer psychology, so you might expect him to react calmly to the surge. But he was annoyed. And yet, what’s the alternative? “If the only choice I have is Uber, then I’m going to expend my outrage and get my Uber,” he says.

So, this is the major point: There are a variety of factors that will affect your decision to spend extra for the Uber, but chief among them is necessity and choice. That is, if you don’t have any other transportation options, you’re just going to suck it up and pay, even if you don’t like it. Unless, of course, you’ve got some patience.

In March 2015, Nicholas Diakopoulos, an assistant professor in the College of Journalism at the University of Maryland, College Park, conducted his own analysis of surge pricing. He examined the surge pricing on one street corner in Washington DC for one day. Notably, he found that at 1:54 p.m., there was a surge of 2.3x. “Yet, just five minutes later, the price multiplier is back to a normal 1.0x,” Diakopoulos wrote. The lesson: sometimes the algorithm can swing wildly in either direction, so if you can afford waiting a few extra minutes, your patience may pay off.

To be sure, Uber is hardly the only company to experiment with dynamic pricing. Online retailers, from Amazon to The Home Depot, have all experimented with fluctuating price tags. As Dholakia says, “Technology now allows companies to change prices every second.” So does this mean to expect companies to constantly change their prices, forcing you, the consumer to play whack-a-mole to get a good deal?

Dholakia doesn’t think so. Eventually, he says, retailers won’t be so random with their prices. Why? “Because it will drive consumers nuts.”