Optimal Price Bargaining in Genshin Impact

by greenturtle3141, Oct 21, 2022, 8:32 PM

Reading Difficulty: 1.5/5

Here's a light read for once.

https://i.imgur.com/RAYxY2J.png

The Premise

Genshin Impact includes minigames in which you negotiate on a price with someone. You get some number of attempts to offer a price until they get very upset. The goal is to purchase what you want by offering the lowest price you can.

Let's formulate this into mathspeak. Let $n$ be a positive integer. The price $p$ of a prize is selected uniformly at random from the interval $[0,1]$, but is not revealed to you. You are to offer a price $x$ between $0$ and $1$.
  • If $x \geq p$, then the prize is sold and you pay $x$.
  • If $x < p$, you're told that the offer is too low, and you must offer another price.
You may get a total of $n$ attempts to offer a price. You must succeed in buying the prize within the $n$ attempts.

What strategy should I follow to minimize the expected value of the price I end up paying?

Example game 1

Let $n=5$.
  1. I offer $0.3$. It's not enough. (I now know that $0.3 < p \leq 1$)
  2. I offer $0.7$. This happens to be enough, and so I end up paying $0.7$ with three attempts to spare.

Example game 2

Let $n=4$.
  1. I offer $0.1$. It's not enough. (I now know that $0.1 < p \leq 1$)
  2. I offer $0.2$. It's still not enough. (I now know that $0.2 < p \leq 1$)
  3. I offer $0.8$. It's still not enough.
  4. I'm out of extra attempts, so I must offer $1$ now to guarantee the purchase. This is indeed enough and I pay $1$.

Solution

We claim that the minimum you need to pay in expectation is ....

The first observation is that we can fully decide which prices to offer beforehand. We shouldn't need to change our strategy in the middle of the game based on what happens. Also, each offer should be higher than the previous ofer. So, let's suppose that our first offer is $x_1$, then the next offer is $x_2$ more than that, and then the next offer increases by another $x_3$, and so on. So our list of offers is:
  • $x_1$
  • $x_1+x_2$
  • $x_1+x_2+x_3$
  • $\cdots$
  • $x_1+x_2+x_3+\ldots+x_n$
If we ever actually have to use up all our offering attempts, then the last offer must be $1$. That means that our variables must be subject to the condtion $x_1+x_2+\ldots+x_n = 1$.

What's the expected value of the amount we end up paying?
  • There's an $x_1$ chance that $0 \leq p \leq x_1$, and if this happens then we pay $x_1$, so one of the terms for the expected value is $x_1(x_1)$.
  • There's an $x_2$ chance that $x_1 < p \leq x_2$, and if this happens then we pay $x_1+x_2$, so the next term is $x_2(x_1+x_2)$.
  • There's an $x_3$ chance that $x_2 < p \leq x_2$, and if this happens then we pay $x_1+x_2+x_3$, so the next term is $x_3(x_1+x_2+x_3)$.
  • $\cdots$
  • There's an $x_n$ change that $x_{n-1} < p \leq x_n$, and if this happens then we pay $x_1+x_2+\ldots+x_n$, so the last term is $x_n(x_1+x_2+\ldots+x_n)$.

Altogether, the expected value is:
$$x_1(x_1) + x_2(x_1+x_2) + x_3(x_1+x_2+x_3)+\ldots+x_n(x_1+\ldots+x_n)$$Using the distributive property, this can be expanded to become
$$(x_1^2+x_2^2+\ldots+x_n^2) + (x_1x_2 + x_1x_3+x_2x_3 + \ldots + x_{n-1}x_n).$$That is, we have the sum of the squares, and then we add up every possible way to multiple an $x_i$ and an $x_j$ (with $i \neq j$).

This reminds me a lot of how you expand $(x_1+x_2+\ldots+x_n)^2$. This is great, because $x_1+x_2+\ldots+x_n=1$, so this could really help simplify things.

Hmm, it's not quite the same expression though, since
$$1 = (x_1+x_2+\ldots+x_n)^2 = (x_1^2+x_2^2+\ldots+x_n^2) + 2(x_1x_2 + x_1x_3+x_2x_3 + \ldots + x_{n-1}x_n).$$But that right side does kinda look like it! Let's do some algebra to "massage" this expression into what the expected value looks like. First, we add $(x_1^2+x_2^2+\ldots+x_n^2)$ to both sides.
$$(x_1^2+x_2^2+\ldots+x_n^2) + 1 = 2(x_1^2+x_2^2+\ldots+x_n^2) + 2(x_1x_2 + x_1x_3+x_2x_3 + \ldots + x_{n-1}x_n)$$Then, we divide by $2$.
$$\frac{(x_1^2+x_2^2+\ldots+x_n^2) + 1}{2} = (x_1^2+x_2^2+\ldots+x_n^2) + (x_1x_2 + x_1x_3+x_2x_3 + \ldots + x_{n-1}x_n)$$And hey, that right side is now the expected value! So
$$\text{Expected Value} = \frac{(x_1^2+x_2^2+\ldots+x_n^2) + 1}{2}.$$Huh, what were we trying to do again? Right, we're trying to find the minimum possible expected value for some nice choices for $x_1,x_2,\cdots,x_n$, and so we're trying to find the minimum possible value of $\frac{(x_1^2+x_2^2+\ldots+x_n^2) + 1}{2}$.

Inequality fans know what's coming! We use the powerful QM-AM inequality!
$$\sqrt{\frac{x_1^2+x_2^2+\ldots+x_n^2}{n}} \geq \frac{x_1+x_2+\ldots+x_n}{n}$$If we rearrange this, we get that
$$x_1^2+x_2^2+\ldots+x_n^2 \geq \frac{(x_1+x_2+\ldots+x_n)^2}{n} = \frac{1}{n}.$$The helpful $x_1+x_2+\ldots+x_n=1$ came to the rescue again! Now,
$$\text{Expected Value} = \frac{(x_1^2+x_2^2+\ldots+x_n^2) + 1}{2} \geq \frac{1/n+1}{2} = \boxed{\frac12+\frac1{2n}},$$which is what I claimed.

But remember, whenever you're proving that something is the minimum, you always have to prove that it's obtainable. Right now, I've only shown that $\frac12+\frac1{2n}$ is a lower bound. If I wanted a lower bound, I could just pick like $-12345$ and be done with it, that's no fun.

The only part where an inequality came in was when we used QM-AM. That means that the only way to obtain the proposed minimum value is to achieve the equality case in the inequality $\sqrt{\frac{x_1^2+x_2^2+\ldots+x_n^2}{n}} \geq \frac{x_1+x_2+\ldots+x_n}{n}$. Fortunately some smart people already figured out that this happens exactly when all the variables are equal, i.e. $x_1=x_2=\ldots=x_n$. Combined with the condition that $x_1+x_2+\ldots+x_n$, we see that the minimum expected value is obtained when we choose $x_1=1/n$, $x_2=1/n$, $\cdots$, and $x_n = 1/n$.

This finishes the proof, and that "equality case" also tells us that the best strategy is to offer $1/n$, then $2/n$, then $3/n$, etc. all the way up to $n/n$.


It's always useful to do a quick sanity check to make sure that the answer you get makes sense.

When I plug in $n=1$, the minimum expected value is $1$. This makes sense because your first offer has to be $1$.

Also, it makes sense that the minimum expected value keeps decreasing the more offers you're allowed to make.

What's interesting is that, no matter how many offers we're allowed to make, we can never do better than $1/2$ in expected value. This probably makes sense, because the expected of value of $p$ in the first place is $1/2$, and we shouldn't anticipate being able to do better than the original expected value.

Hm, this makes me wonder what happens if $p$ was not chosen with a uniform distribution... Will it always be the case that we can't do better than $\mathbb{E} p$? Exciting!
This post has been edited 2 times. Last edited by greenturtle3141, Oct 21, 2022, 8:35 PM

Comment

3 Comments

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.
I love you

by cherryserendipity, Oct 21, 2022, 8:38 PM

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.
tf this is genshin

by carolynlikesmath, Oct 22, 2022, 4:52 PM

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.
the career of using olympiad math to determine things in video games is a good career
see, math does have an application in real life
stay in school kids

by akliu, Oct 22, 2022, 4:53 PM

Turtle math!

avatar

greenturtle3141
Archives
+ October 2024
Shouts
Submit
  • this blog is so orz

    by ESAOPS, May 10, 2025, 6:51 PM

  • Can you give some thought to dropping a guide to STS? Just like how you presented your research (in your paper), what your essays were about, etc. Also cool blog!

    by Shreyasharma, Mar 13, 2025, 7:03 PM

  • this is so good

    by purpledonutdragon, Mar 4, 2025, 2:05 PM

  • orz usamts grader

    by Lhaj3, Jan 23, 2025, 7:43 PM

  • Entertaining blog

    by eduD_looC, Dec 31, 2024, 8:57 PM

  • wow really cool stuff

    by kingu, Dec 4, 2024, 1:02 AM

  • Although I had a decent college essay, this isn't really my specialty so I don't really have anything useful to say that isn't already available online.

    by greenturtle3141, Nov 3, 2024, 7:25 PM

  • Could you also make a blog post about college essay writing :skull:

    by Shreyasharma, Nov 2, 2024, 9:04 PM

  • what gold

    by peace09, Oct 15, 2024, 3:39 PM

  • oh lmao, i was confused because of the title initially. thanks! great read

    by OlympusHero, Jul 20, 2024, 5:00 AM

  • It should be under August 2023

    by greenturtle3141, Jul 11, 2024, 11:44 PM

  • does this blog still have the post about your math journey? for some reason i can't find it

    by OlympusHero, Jul 10, 2024, 5:41 PM

  • imagine not tortoise math

    no but seriously really interesting blog

    by fruitmonster97, Apr 2, 2024, 12:39 AM

  • W blog man

    by s12d34, Jan 24, 2024, 11:37 PM

  • very nice blog greenturtle it is very descriptive and fascinating to pay attention to :-D

    by StarLex1, Jan 3, 2024, 3:12 PM

68 shouts
Tags
About Owner
  • Posts: 3563
  • Joined: Oct 14, 2014
Blog Stats
  • Blog created: Oct 23, 2021
  • Total entries: 60
  • Total visits: 126958
  • Total comments: 126
Search Blog
a