Problem 286

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
Taifu
Posts: 34
Joined: Sun Jan 13, 2008 8:38 pm

Problem 286

Post by Taifu »

Just nitpicking: for each successful shot you have 2 points (or even 3 depending from distance!) in Basketball.

Perhaps "points" is not the better wording :-)

Ciao.
Marco.
Image
Listing
Posts: 7
Joined: Thu Jan 22, 2009 12:01 pm

Re: Problem 286

Post by Listing »

Somehow I always get q=90.1546080185 but it seems to be wrong :?

Is it some rounding mistake or am I completely off?
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Problem 286

Post by stijn263 »

You're completely off I'm afraid. Each shot scores one point only.

Good luck! (Problem 286 (View Problem))
Listing
Posts: 7
Joined: Thu Jan 22, 2009 12:01 pm

Re: Problem 286

Post by Listing »

I solved it, thanks for your post. Stupid me calculated it for 20 misses and not for 20 hits :D
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 286

Post by MaJJ »

Is q=54.4656158489 too far away to be a rounding error?
Image
Image
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 286

Post by jaap »

MaJJ wrote:Is q=54.4656158489 too far away to be a rounding error?
Yes, even the integer part is not correct.
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 286

Post by MaJJ »

Thanks. I'll ask another question:

Can I use "average probability" in binomial distribution?

Code: Select all

def p(x,q): return 1-(x/q)

def avg(q):
    s = 0
    for xx in range(1,51):
        s += p(xx,q)
    s /= 50
    return s
and then find out the probability (the wanted 2%) with something like (n choose k) * (avg(q) ** k) * ((1 - avg(q)) ** n-k) ?

EDIT: or, more precisely, where is the reasoning incorrect? I know I can't use it like that, b/c it provides wrong result :)
Image
Image
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 286

Post by jaap »

MaJJ wrote:EDIT: or, more precisely, where is the reasoning incorrect? I know I can't use it like that, b/c it provides wrong result :)
Look at a simpler case: 2 distances, with individual probabilities 5%, 95% and you want to score exactly once.

Your method:
Average is 50%. Scoring exactly 1 out of 2 with 50% each is
0.5 * (1-0.5) + (1-0.5) * 0.5 = 0.5

Actual probability of scoring exactly 1 out of 2 with probabilities 5%, 95% is
0.05 * (1-0.95) + (1-0.05) * 0.95 = 0.905

The question is, why would you expect this to give the same answer?
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 286

Post by MaJJ »

Thanks for putting me on the right track.
I'm beginner in the field of probability, so I'm learning quite a lot from this PE problem :)

I'm trying to do it your way - but I'm still struggling with it.

Is probability of scoring 2 out of 2 with probabilities 5%, 95% this?

Code: Select all

0,05 * 0,95 = 0,0475
And for three distances with probabilities 50%, 60% and 70%:
Scoring 1 out of 3:

Code: Select all

   0,5  * (1-0,6) * (1-0,7) +
(1-0,5) *    0,6  * (1-0,7) +
(1-0,5) * (1-0,6) *    0,7  = 0,29
Scoring 3 out of 3:

Code: Select all

0,5 * 0,6 * 0,7 = 0,21
But what is the probability of scoring 2 out of 3?
This is wrong, but I didn't find a way how to calculate it correctly:

Code: Select all

   0.5  *    0.6  * (1-0.7) +
   0.5  * (1-0.6) *    0.7  +
(1-0.5) *    0.6  *    0.7  = 0.44 <--- too high
I tried to do it this way because I thought the possibilities are ABC or ABC or ABC (   denoting scoring this ball)
Image
Image
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 286

Post by Lord_Farin »

MaJJ wrote: But what is the probability of scoring 2 out of 3?
This is wrong, but I didn't find a way how to calculate it correctly:

Code: Select all

   0.5  *    0.6  * (1-0.7) +
   0.5  * (1-0.6) *    0.7  +
(1-0.5) *    0.6  *    0.7  = 0.44 <--- too high
I tried to do it this way because I thought the possibilities are ABC or ABC or ABC (   denoting scoring this ball)
As far as I have ever done statistics, that is in fact the correct way to calculate it, as the throws are all assumed to be independent.
Image
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 286

Post by jaap »

MaJJ wrote:Is probability of scoring 2 out of 2 with probabilities 5%, 95% this?

Code: Select all

0,05 * 0,95 = 0,0475
Yes.
MaJJ wrote:And for three distances with probabilities 50%, 60% and 70%:
Scoring 1 out of 3: [...] = 0,29
Scoring 3 out of 3: [...] = 0,21
[...]
scoring 2 out of 3 [...] = 0.44
That is all correct. Together with:
Scoring 0 out of 3: (1-0.5) * (1-0.6) * (1-0.7) = 0.06
that makes the total exactly 1, which it should because they are mutually exclusive and include all the possible cases that could happen.
dharasty
Posts: 6
Joined: Wed Apr 25, 2012 3:32 pm

Re: Problem 286

Post by dharasty »

I suggest that the wording of the problem is VERY POOR. In basketball, "scoring 20 points" is not the same as sinking 20 shots, since a "shot" can add 2 or 3 *points* to the "score". I saw that ambiguity when I read the problem, and thought "gee, somebody who doesn't know the rules and terminology of basketball might not be able to get this problem, as that information is not provided. They really should update the wording."

Now I realize the problem author is not familiar with the rules and terminology of basketball. The problem really is asking about "making 20 shots", not "scoring 20 points".

I was able to overcome this unfortunate choice of wording since I a) saw the ambiguity, and, b) proved to myself it was mathematically impossible to have exactly a 2% chance of sinking exactly 10 shots (for 20 true "points").

PLEASE update the wording of the problem to state: "score a total of exactly 20 times" or "sink a total of exactly 20 shots". Please do not use the word "points" unless you mean it in the sense that basketball players do.

All Project Euler questions aim to be VERY PRECISE in their wording. This one -- as of this date -- alas, is not.

Thanks for considering this.
Image
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 286

Post by TripleM »

I agree that the wording is slightly unfortunate and it wouldn't hurt to change it, but I disagree that there is any ambiguity / lack of precision in the problem statement itself. It defines the probability of scoring a point from a distance, and then asks you to calculate something involving the probability of scoring 20 points. The only way you could misunderstand that is if you try to you try to read between the lines, use the real rules of basketball, and make assumptions that you shouldn't - the details provided by the problem are perfectly precise.
oleglyamin
Posts: 39
Joined: Mon Aug 08, 2011 8:49 am

Re: Problem 286

Post by oleglyamin »

I'm trying to identify the source of error - whether it's in the part related to probabilities or in the part related to handling large and small numbers.

Could you tell me how close I am?
xxxxxx (edit by hk)(rounded to 5 decimal places)

Thanks.

EDIT: Found it. It was numerical error.
User avatar
yourmaths
Posts: 47
Joined: Mon Aug 25, 2014 11:00 am

Re: Problem 286

Post by yourmaths »

dharasty wrote: Fri Apr 27, 2012 2:01 pma "shot" can add 2 or 3 *points* to the "score".
Wouldn't this depend on how far out the 3-point line extends? Also there are no units (feet/metres?) for the distances in the problem statement. At any rate, my understanding is that the only way to score one point in basketball is with a free throw, i.e. similar to what is happening in the problem statement, albeit at different distances.

At this point (lol) most people would probably come and look here for clarification. But I agree, the use of "point" in relation to a basketball problem is probably unfortunate. Maybe change it to golf.
level = lambda number_solved: number_solved // 25
Image
Post Reply