Page 1 of 1

Problem 285

Posted: Sat Apr 03, 2010 5:39 am
by Raichev_2
From the problem page:
"For example, if k = 6, a = 0.9 and b =  0.55, then (k·a+1)^(2) + (k·b+1)^(2) = 40.05."
but:
(k·a+1)^2 + (k·b+1)^2
=(6·0.9+1)^2 + (6·0.55+1)^2
=6.4^2 + 4.3^2 = 59.45

Am I missing something or being unbelievably thick and failing at simple arithmetic?

Re: Problem 285

Posted: Sat Apr 03, 2010 8:04 am
by harryh
Good spot ! There is a mistake in the given example; it will be fixed soon.

Edit: Typos fixed. The actual values are a=0.2, b=0.85, calculated sum=42.05, sq.root=6.484...

Re: Problem 285

Posted: Sat Apr 03, 2010 8:08 am
by amlesh44
Also, is the given expected value for 1 <= k <= 10 correct? I am consistently getting something other than the given value...though that could just be cause I am wrong :lol:.

Re: Problem 285

Posted: Sat Apr 03, 2010 8:37 am
by torrocus
Raichev_2 wrote:From the problem page:
"For example, if k = 6, a = 0.9 and b =  0.55, then (k·a+1)^(2) + (k·b+1)^(2) = 40.05."
but:
(k·a+1)^2 + (k·b+1)^2
=(6·0.9+1)^2 + (6·0.55+1)^2
=6.4^2 + 4.3^2 = 59.45

Am I missing something or being unbelievably thick and failing at simple arithmetic?
I also noticed the same mistake. I joined the Project Euler yesterday. At first I thought I didn't understand the task. Now it's clear.

Re: Problem 285

Posted: Sat Apr 03, 2010 1:20 pm
by GenePeer
I joined project euler a while back, but i've only been doing the first problems. reached Problem 55 but now i decided to do this problem. I'm really confused on how they calculated the expected value. Could someone post a link or atleast explain how the expected value for the example given was calculated? I'm new to the whole Uniform Distribution concept but i'm open to learn new things :D

Re: Problem 285

Posted: Sat Apr 03, 2010 3:34 pm
by zwuupeape
Tried, gave up, took a break, tried again - I suspect I might have precision problems. I get exactly the same value for k = 10.

Can anyone confirm:

k = 1000 => 1556.17575
k = 10000 => 15688.738433

Re: Problem 285

Posted: Sat Apr 03, 2010 4:09 pm
by Listing
zwuupeape wrote:Tried, gave up, took a break, tried again - I suspect I might have precision problems. I get exactly the same value for k = 10.

Can anyone confirm:

k = 1000 => 1556.17575
k = 10000 => 15688.738433
k = 10000 => 15688.738431

Re: Problem 285

Posted: Sat Apr 03, 2010 5:37 pm
by zwuupeape
Yeah, thanks - I got it now :).

Re: Problem 285

Posted: Sat Apr 03, 2010 7:04 pm
by dbatche3
I am pretty sure I have the right idea for this one, except that my result for k up to 10 is 10.91995. My results for k up to 1000 and k up to 10000 are also similar to the ones posted above, except slightly bigger. I am pretty sure I'm doing something incredibly stupid, my hope is that by posting this it will get my mind to go in gear.

Re: Problem 285

Posted: Sat Apr 03, 2010 9:19 pm
by Listing
dbatche3 wrote:I am pretty sure I have the right idea for this one, except that my result for k up to 10 is 10.91995. My results for k up to 1000 and k up to 10000 are also similar to the ones posted above, except slightly bigger. I am pretty sure I'm doing something incredibly stupid, my hope is that by posting this it will get my mind to go in gear.
k=1 is a special case which needs to be handled manually

Re: Problem 285

Posted: Sun Apr 04, 2010 8:15 pm
by dbatche3
I think I figured out my problem, I was assuming that conditions in the limiting case would hold in all cases. I was wrong. Now I just need to make sure all my code is correct...

Re: Problem 285

Posted: Mon Apr 05, 2010 11:34 am
by umisef
k=1 is a special case which needs to be handled manually
For future seekers of help --- this means that the numbers quoted in the earlier posts are for k=2...n, NOT 1...n.
Also, the value for 1000 should be 1556.175760...

(I spent quite some time trying to find my fundamental problem, when in fact I "only" had precision problems, because I didn't realise those values didn't include k=1)

Re: Problem 285

Posted: Tue Apr 06, 2010 6:13 pm
by mrtollefson
I can't get the sample problem, and I'm not doing anything special for k=1, so I presume for now that that's effect and cause.

Can someone elaborate some more about the specialty of k=1?

Thanks.
...mrt

Re: Problem 285

Posted: Thu Apr 08, 2010 1:01 pm
by sfabriz
Very hard to elaborate on k=1, and the reason is that it would spoil the problem solution.
Try to understand what you're doing and you'll also understand immediately why k=1 is kind of "special".
Cheers,
sfabriz

Re: Problem 285

Posted: Thu Apr 08, 2010 4:54 pm
by mrtollefson
Thanks. While not seeing yet what I'm supposed to be looking for, I can see how that might be so. :)

Asking another way, then, for 65,536 attempts, I got 491 K=1's, for an EV(1) of 0.007492. For 10^6 attempts I got 7293 K=1's for an EV(1) of .0007293. In 65,536 attempts, I got 16942 K=2's for an EV(2) of 0.517029, and for 10^6 attempts I got 259497 K=2's for an EV(2) of 0.518994.

I know this isn't how to do the final problem. 10^5 loops around 10^6 loops can't be the way. But I wonder if my built-in RAND() function is the wrong one. Are those EV() in line?

...mrt

Re: Problem 285

Posted: Sat Apr 10, 2010 5:53 am
by dbatche3
mrtollefson wrote:Thanks. While not seeing yet what I'm supposed to be looking for, I can see how that might be so. :)

Asking another way, then, for 65,536 attempts, I got 491 K=1's, for an EV(1) of 0.007492. For 10^6 attempts I got 7293 K=1's for an EV(1) of .0007293. In 65,536 attempts, I got 16942 K=2's for an EV(2) of 0.517029, and for 10^6 attempts I got 259497 K=2's for an EV(2) of 0.518994.

I know this isn't how to do the final problem. 10^5 loops around 10^6 loops can't be the way. But I wonder if my built-in RAND() function is the wrong one. Are those EV() in line?

...mrt
Those are reasonable approximations of the real expected values.

Re: Problem 285

Posted: Fri Nov 28, 2014 4:37 am
by jpaulson
I believe the values posted for k=1000 and k=10000 earlier in this thread were wrong. My AC program gets:
k=1,000 => 1556.18298
k=10,000 => 15688.74566

Re: Problem 285

Posted: Fri Apr 26, 2019 2:48 am
by yourmaths
jpaulson wrote: Fri Nov 28, 2014 4:37 am I believe the values posted for k=1000 and k=10000 earlier in this thread were wrong. My AC program gets:
k=1,000 => 1556.18298
k=10,000 => 15688.74566
I have just completed this problem and I can confirm that these are the correct values. I'm not sure what is going on in the rest of this thread.