While shopping, you find an item with a random price evenly distributed between $0 and $60. You buy as many of these items as possible with the $60 you brought.
What is the expected amount of money you have spent (in dollars)?
Note: You may assume that $60 is large compared to a penny so that the distribution of prices is essentially continuous.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
That's a concise way of expressing the expected value that needs to be calculated. But it's interesting to see how you've gone about to evaulate that floor function. If one tries to put that integral in Wolfram Alpha, it won't return a value.
Log in to reply
It gives me a numerical answer accurate to 4 SF which is, sadly, enough to get the correct answer for the question.
Making the argument of a floor function a simple variable, and then splitting the integral into strips of width 1 , is the standard approach to handling integrals involving the floor function.
I'm consistently getting around 43 with MC.
Log in to reply
I imagine you are suffering from rounding errors. You are having to multiply things that can be very small, like x , by things that can be very large, like the integer part of {60/x). Add to this the fact that small values of x make an important contribution to the sum...
What happens if you try to calculate the y integral instead?
Me too, numerically, by MC, I get something like 43.09. I have also developed a theoretical analysis, which is quite involved, that provides that the correct result is 60(e-2), where e is Neper number, and this is actually equal to 43.0969....
Log in to reply
Well, I and Michael have both provided elementary proofs of the 5 π 2 result. If you want to post your calculations, I will critique them for you.
Log in to reply
@Mark Hennings – I'll try to summarize my findings. I think that the main difference with respect to your and Michael's solutions is that in order to establish that it takes n draws of items not to spend more than $60, you need to also draw the (n+1)-item. Actually, this is what one would do when implementing a MC method: keep picking items until the total cost exceeds $60, say at the n+1 item, so that you actually can afford to buy only n items. Based on that, I first computed the distribution of probability of the number of items, i.e., p(n) = probability that it takes exactly n items not to exceed $60, provided that the total cost of n+1 items exceeds $60. Then I computed the mean cost associated with the different n, i.e., C(n) = mean cost spent by collecting n items, under the same conditions on n as for p(n). Finally, I computed the mean cost by summing the product p(n) C(n) for n>=1. The result of this computation is that the mean cost is $60(e - 2), where e is Neper number, which amounts to 43.0969. This value and also the distributions p(n) and C(n) match very well the MC results, beyond any reasonable doubt (I used 10^6 samples).
Log in to reply
@Stefano Micheletti – You do not need to draw n + 1 items to know whether you can pay for them or not - you know when you look at the first of these items what it costs, and so you can work out (by dividing the cost into 6 0 and taking the integer part) exactly how many you can buy, since once the costs per item is established, all items cost the same.
The bottom line is that your MC method is probably not implementing a uniform distribution of costs. The cost of an item should be a continuous random variable X with probability distribution function f ( x ) = { 6 0 1 0 0 < x < 6 0 o . w . If you are going to apply a MC method here, you need to do something like this:
I did this quickly in Mathematica, obtaining C as 60RandomReal[] . A quick run-through for 1 0 0 0 0 0 samples gave me expected values of T consistently between 4 9 . 3 and 4 9 . 4 , where it belongs.
I think you are solving a different problem. You are choosing a sequence of items at different costs, and keep on doing so until the total cost exceeds 6 0 . This sort of problem does give expected values involving e , but this is not what is going on here.
Log in to reply
@Mark Hennings – Thanks Mark for your answer. Now it's clear what the original problem dealt with. Actually, I did what you mention at the bottom. That was how I understood the original question. I did implement correctly the MC method, but not as you suggested, of course, but consistently with my interpretation of the problem. Indeed, we are solving two different problems. I encourage you to try and work out my problem too, since it appears to me to be much more involved to attack than the original one.
Log in to reply
@Stefano Micheletti – If X 1 , X 2 , . . . are independent U ( 0 , 1 ) random variables, it is a simple induction that P [ X 1 + X 2 + ⋯ + X n ≤ x ] = n ! x n 0 < x ≤ 1 , n ∈ N This probability is much more complex for x > 1 , but never mind. We deduce that part of the p.d.f. of X 1 + X 2 + ⋯ + X n is equal to f X 1 + X 2 + ⋯ + X n ( x ) = ( n − 1 ) ! x n − 1 0 < x ≤ 1 , n ∈ N If N is the number of X j required to add to more than 1 , and T is the largest running total of the X j that is less than 1 , then P [ T ≤ x , N = n ] = P [ X 1 + X 2 + ⋯ + X n − 1 ≤ x , X 1 + X 2 + ⋯ + X n > 1 ] = ∫ 0 x f X 1 + X 2 + ⋯ + X n − 1 ( y ) P [ X n > 1 − y ] d y = ∫ 0 x ( n − 2 ) ! y n − 2 y d y = n ( n − 2 ) ! x n = n ! ( n − 1 ) x n = ( n − 1 ) ! x n − n ! x n for 0 ≤ x ≤ 1 and n ≥ 2 and hence P [ T ≤ x ] = n ≥ 2 ∑ P [ T ≤ x , N = n ] = x ( e x − 1 ) − ( e x − 1 − x ) = ( x − 1 ) e x + 1 0 ≤ x ≤ 1 Thus T has p.d.f. f T ( x ) = { x e x 0 0 < x < 1 o . w . and hence the expected value of T is E [ T ] = ∫ 0 1 x 2 e x d x = e − 2 Which makes the answer to your question 6 0 E [ T ] = 6 0 ( e − 2 ) .
Log in to reply
@Mark Hennings – Brilliant! I did it in a completely different way, but yours is theoretically neater and more elegant. By the way, how can you incorporate Latex commands in your posts, if this is the case?
Log in to reply
@Stefano Micheletti – \ a l p h a works, but is a bit of a cheat (I am typing \backslash\mathrm{alpha} in a math environment).
In other implementations of LaTeX, the command \verb does the trick, but that does not seem to be implemented here.
Log in to reply
@Mark Hennings – Thanks, I'll try!
Log in to reply
@Stefano Micheletti – OK, so $ is the verbatim toggle here... Well, not quite, since \ ( and \ ) commands are still active inside $.
The expected value is that area of this square with the [infinite number of] triangles as marked subtracted from it, divided by the length of its side. The slope of the blue lines are 1 , 2 , 3 , 4 , 5 , . . . . Any integer multiple of any value x will be at the red bottoms of those triangles, if less the height of the square.
For an unit square, this area is
1 − n = 1 ∑ ∞ ( 2 1 n + 1 1 ( n 1 − n + 1 1 ) ) = 1 − 2 1 n = 1 ∑ ∞ n ( n + 1 ) 2 1 = 1 2 π 2
To prove the above result, first we start with
n = 1 ∑ ∞ ( n 1 − n + 1 1 ) = 1 = n = 1 ∑ ∞ n ( n + 1 ) 1 = n = 1 ∑ ∞ n ( n + 1 ) 2 n + 1 = n = 1 ∑ ∞ ( ( n + 1 ) 2 1 + n ( n + 1 ) 2 1 )
Now, we know from the Basel Problem that
n = 1 ∑ ∞ ( n + 1 ) 2 1 = − 1 + 6 π 2
so that
n = 1 ∑ ∞ n ( n + 1 ) 2 1 = 2 − 6 π 2
Thus, the final expected value is 6 0 ⋅ 1 2 π 2 = 5 π 2
Alternative:
Let us denote amount of capital we have with c , price of a random item with p , number of items we can afford with n and money we spent by buying n items priced $ p with s = n p . The following relationships hold when n = k :
k + 1 c < p ≤ k c
E [ s k ] = 2 k ( p m a x + p m i n ) = 2 c k ( k 1 + k + 1 1 ) (based on uniform probability distribution)
P ( n = k ) = k 1 − k + 1 1
If we denote money spent with S , we have:
E [ S ] = k = 1 ∑ ∞ E [ s k ] ⋅ P ( n = k ) = k = 1 ∑ ∞ 2 c k ( k 1 + k + 1 1 ) ( k 1 − k + 1 1 ) = 2 c k = 1 ∑ ∞ k ( k 2 1 − ( k + 1 ) 2 1 ) = 2 c k = 1 ∑ ∞ k 1 − k + 1 1 + ( k + 1 ) 2 1 = 2 c ( 1 + k = 2 ∑ ∞ k 1 − k = 2 ∑ ∞ k 1 + k = 1 ∑ ∞ k 2 1 − 1 ) = 2 c k = 1 ∑ ∞ k 2 1 = c 1 2 π 2
By the way, I'm struggling to understand your square analogy. Could you explain it further?
Log in to reply
Oh, I got it. It can be interpreted to be similar to my reasoning.
Log in to reply
yeah, it started out by plotting how much money would be spent given the cost of any particular item.
It is probably easiest to evaluate the sum as you had first written it and not rewriting as n ( n + 1 ) 2 1 . You can just distribute the n + 1 1 to get n ( n + 1 ) 1 (a telesoping series) minus ( n + 1 ) 2 1 (a shifted basel problem).
Log in to reply
ahh maybe so, I could have gone that way
I actually first figured 2 1 n ( n + 1 ) 2 1 as the area of the triangles just from looking at the figure, and then decided to break it down for clarity later, on the left side.
DEAR AUTHOR! please correct the text so the conditions of that "shopping" would be more clear! at this moment there are two ways of interpreting this puzzle's text and these two ways they lead to different solutions! (maybe not just two ways, maybe there's even more)
Let us denote amount of capital we have with c , price of a random item with p , number of items we can afford with n and money we spent by buying n items priced $ p with s = n p . The following relationships hold when n = k :
k + 1 c < p ≤ k c
E [ s k ] = 2 k ( p m a x + p m i n ) = 2 c k ( k 1 + k + 1 1 ) (based on uniform probability distribution)
P ( n = k ) = k 1 − k + 1 1
If we denote money spent with S , we have:
E [ S ] = k = 1 ∑ ∞ E [ s k ] ⋅ P ( n = k ) = k = 1 ∑ ∞ 2 c k ( k 1 + k + 1 1 ) ( k 1 − k + 1 1 ) = 2 c k = 1 ∑ ∞ k ( k 2 1 − ( k + 1 ) 2 1 ) = 2 c k = 1 ∑ ∞ k 1 − k + 1 1 + ( k + 1 ) 2 1 = 2 c ( 1 + k = 2 ∑ ∞ k 1 − k = 2 ∑ ∞ k 1 + k = 1 ∑ ∞ k 2 1 − 1 ) = 2 c k = 1 ∑ ∞ k 2 1 = c 1 2 π 2
Problem Loading...
Note Loading...
Set Loading...
We want to calculate E = 6 0 1 ∫ 0 6 0 x ⌊ x 6 0 ⌋ d x With the substitution x = y 6 0 , this becomes E = 6 0 ∫ 1 ∞ y 3 ⌊ y ⌋ d y = 6 0 n = 1 ∑ ∞ n ∫ n n + 1 y 3 d y = 3 0 n = 1 ∑ ∞ n ( n 2 1 − ( n + 1 ) 2 1 ) = 3 0 n = 1 ∑ ∞ ( n 1 − n + 1 1 + ( n + 1 ) 2 1 ) = 3 0 ( 1 + n = 2 ∑ ∞ n 2 1 ) = 3 0 ζ ( 2 ) = 5 π 2