Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2011-12-05 13:08:03

juantheron
Member
Registered: 2011-10-19
Posts: 312

probability

Three numbers are chosen at random between 0 and 1. What is the probability that the greatest minus the least is less than

Offline

#2 2011-12-06 03:20:01

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: probability

Answer is somewhere around 0.26 or 26% chance according to below BASIC program.
First run of program:
1-(73915/99999) = 0.26084261
26086/99999 = 0.26086261
Second run of program:
1-(73729/99999) = 0.26270263
26272/99999 = 0.26272263
Third run of program:
1-(74037/99999) = 0.2596226
25965/99999 = 0.2596526
Fourth run of program:
1-(73973/99999) = 0.2602626
26031/99999 = 0.2603126


jyes = 0
jall = 0
jdblcheck = 0


for jiterate = 1 to 99999
  for x = 1 to 3
    ja=rnd(1)
    jb=rnd(1)
    jc=rnd(1)
  next x
  jdif1=ja - jb
  jdif2= ja - jc
  jdif3 = jb - jc
  jdif1 = abs(jdif1)
  jdif2 = abs(jdif2)
  jdif3 = abs(jdif3)
'print jdif1
'print jdif2
'print jdif3
if (jdif1>0.3333) or (jdif2>0.3333) or (jdif3>0.3333) then
   jyes = jyes + 1
end if
if (jdif1<0.33334) and (jdif2<0.33334) and (jdif3<0.33334) then
   jdblcheck = jdblcheck + 1
end if

jall = jall+1

next jiterate


print "1-(";jyes;"/";jall;") = ";1 - (jyes/jall)
print jdblcheck;"/";jall;" = ";jdblcheck/jall

igloo myrtilles fourmis

Offline

#3 2011-12-06 15:41:39

TheDude
Member
Registered: 2007-10-23
Posts: 361

Re: probability

The exact answer I'm getting is 21/81.


Wrap it in bacon

Offline

#4 2011-12-06 21:53:23

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: probability

Wow!!!!!  I had no idea calculus could be involved in probability!!!!  This is an amazing work.  I only wish I could understand it all.  I can follow the calculus, but I don't understand how to set up the problems and add them together and why, but I am very impressed, nevertheless, and the answer is within 1% of the computer's answer too.``


igloo myrtilles fourmis

Offline

#5 2011-12-06 22:46:48

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,713

Re: probability

Impressive answer, TheDude


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#6 2011-12-07 02:03:39

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: probability

hi everyone,

I've got another method, which I think should work,  but it doesn't.  sad:(

Maybe someone can tell me where I'm going wrong.

BUT FIRST,

John:  Great simulation program.  Hope you don't mind but I copied it into my version of BASIC and ran it.

Then, cheeky I know, I made a few changes.

Firstly, you don't need this loop.  I expect you made it when you had an array for the three numbers.  That cuts the run time a lot.

for x = 1 to 3
    ja=rnd(1)
    jb=rnd(1)
    jc=rnd(1)
  next x

Then I 'REM'ed out the PRINT lines for

'print jdif1
'print jdif2
'print jdif3

as you only need them whilst de-bugging.

That made the run time so short I found I could increase the repeats to 10 000 000.

You'll be pleased to know at that number 'jyes' and 'jdblcheck' give the same values and also, the probability then comes out to TheDude's theoretical calculation.  (Nice work, Dude smile )

Now to my method.

The three variables have uniform distribution over the range 0 to 1.

Take any pair, let's say, X and Y.

Then X-Y has a triangular distribution with zeros at the extremes of -1 and + 1, and rising to a maximum of 1 at the centre of the range.

I wasn't 100% sure about the triangular distribution but I've run a simulation 100 000 times and it is.

The probability that -1/3 < X-Y < +1/3 is a simple matter of calculating the area between -1/3 and + 1/3 (no calculus needed), and that comes out to be 5/9.

I've checked that too, with another simulation.

Now I come to the confusing bit; thanks for reading this far:

If G stands for greatest and L for least surely

is the same as

which is

I'm guessing this is where my thinking is wrong, but I cannot see why.  Any ideas?

Thanks,

Bob

Last edited by Bob (2011-12-07 02:10:55)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#7 2011-12-07 03:22:25

TheDude
Member
Registered: 2007-10-23
Posts: 361

Re: probability

John E. Franklin wrote:

Wow!!!!!  I had no idea calculus could be involved in probability!!!!  This is an amazing work.  I only wish I could understand it all.  I can follow the calculus, but I don't understand how to set up the problems and add them together and why, but I am very impressed, nevertheless, and the answer is within 1% of the computer's answer too.``

It gets really complicated really fast for something like bell curves (I don't think they even have closed form solutions), but a uniform probability distribution is pretty straightforward.  You take the integral of 1 from the lowest value to the highest value that you're interested in.  For example, to find the probability that a randomly drawn number is between 1/2 and 3/4:

which is what you'd expect.  This makes it really nice for calculating problems involving multiple probabilities.  For example, to find the probability that the first number drawn is less than 1/2 and the second number is between 1/3 and 2/3:

Again, this matches our intuition.  For this problem we are drawing 3 numbers so we need a triple integral.  I skipped showing the innermost integral in my first post since it was late and I didn't want to do that much LaTeX, and doing an integral of 1 is straightforward enough.

The important thing to keep in mind for this problem is that you have 2 breakpoints: 1/3 and 2/3.  For example, consider a simplified problem where we want to find the probability that 2 randomly drawn numbers are separated by 1/3 or less.  If our first number x is between 1/3 and 2/3 then there our second number y can be anywhere between x - 1/3 and x + 1/3, which has a 2/3 chance of happening.  But if x is less than 1/3 then y must be between 0 and x + 1/3, which has a x + 1/3 chance of happening.  So we need to handle these situations differently.

For the main problem we identified 4 distinct cases.  Here's my logic behind each of them:

Case 1 - x is less than 1/3, y is less than x.  Since x and y are both less than 1/3 this means that it is impossible for z to be too small, or in other words z is bounded below by 0.  It is bounded from above by the smaller of x and y, which in this case is y.  So overall we have 0 <= x < 1/3, 0 <= y <= x, and 0 <= z <= y + 1/3.  The integral for this is

Case 2 - x is less than 1/3, y is greater than x but less than 1/3.  Again, since x and y are both less than 1/3 then z is bounded below by 0.  As with case 1 it is bounded above by the smaller of x and y, which in this case is x.  Overall we have 0 <= x < 1/3, x <= y < 1/3, 0 <= z <= x + 1/3.  Our integral for this is

Case 3 - x is less than 1/3, y is greater than 1/3 but less than x + 1/3.  Now z is bounded below by y and above by x, giving us 0 <= x < 1/3, 1/3 <= y <= x + 1/3, y - 1/3 <= z <= x + 1/3.  This gives us

Case 4 - x is between 1/3 and 2/3, y is greater than x - 1/3 and less than x.  In this case z is bounded below by x and above by y, giving us 1/3 <= x <= 2/3, x - 1/3 <= y <= x, x - 1/3 <= z <= y + 1/3.

There is exactly 1 equivalent mirror case for each of these 4 cases, so adding these probabilities together and multiplying by 2 will give you the final answer.

Last edited by TheDude (2011-12-07 03:24:56)


Wrap it in bacon

Offline

#8 2011-12-07 03:37:50

TheDude
Member
Registered: 2007-10-23
Posts: 361

Re: probability

bob bundy wrote:

Now I come to the confusing bit; thanks for reading this far:

If G stands for greatest and L for least surely

is the same as

which is

I'm guessing this is where my thinking is wrong, but I cannot see why.  Any ideas?

Thanks,

Bob

The problem is that by multiplying them together like that you're treating all 3 as independent events.  5/9 * 5/9 * 5/9 is the probability that, on 3 distinct occasions, you drew 2 random numbers that were within 1/3 of each other.  To solve the problem with this method I think you'll need to use http://en.wikipedia.org/wiki/Conditional_probability , which is what I tried at first but failed to do.


Wrap it in bacon

Offline

#9 2011-12-07 04:04:59

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: probability

hi TheDude,

Thanks for responding.

But my thinking was this.

As we want the greatest difference, if they are all inside that, we must have captured the greatest.

Oh!  Maybe the other two (that aren't the G/L pair) may be less restricted.

if (jdif1<0.33334) and (jdif2<0.33334) and (jdif3<0.33334) then
   jdblcheck = jdblcheck + 1

This bit in John's program does work?

I going to have to do more thinking ........... dizzy

Bob

Last edited by Bob (2011-12-07 04:13:53)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#10 2011-12-07 08:01:31

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: probability

Holy wow!!!  There's a lot of great material to study here now!!! Thanks so much for all the work everyone.


igloo myrtilles fourmis

Offline

#11 2011-12-07 08:59:20

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: probability

I'm starting to get a clue on what the dude is saying.  I had forgotten the part that we have to take the lowest and highest of the three.  This is why the dude picks a z that is between the lowest between x and y and then jumps up a third on his first two examples in post 7.  I still have to investigate some more.  This is really educational stuff.


igloo myrtilles fourmis

Offline

#12 2011-12-07 09:18:10

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: probability

Here's a question I have for the dude:
  Does the logic in setting up each scenario force the order of the 3 integrations.
In other words, I noted you integrate by z first, the most tightly bound one.
Is it required that you integrate in the z,y,x order?   Also I haven't read the
conditional prob stuff in wiki yet, maybe I should...


igloo myrtilles fourmis

Offline

#13 2011-12-07 10:50:21

TheDude
Member
Registered: 2007-10-23
Posts: 361

Re: probability

I'm not sure.  Intuitively I would think that you could integrate in any order, but I haven't actually tried.  I set up the integrations from most to least tightly bound because that was the easiest way for me to visualize and set up the problem.


Wrap it in bacon

Offline

#14 2011-12-07 11:56:30

TheDude
Member
Registered: 2007-10-23
Posts: 361

Re: probability

bob bundy wrote:

if (jdif1<0.33334) and (jdif2<0.33334) and (jdif3<0.33334) then
   jdblcheck = jdblcheck + 1

This bit in John's program does work?

I going to have to do more thinking ........... dizzy

Bob

Yes, that works because the numbers have already been determined and at this point in the program he's just checking that they fit the criteria.  This same logic doesn't work when using probabilities because they are conditional.  As you showed there is a 5/9 chance that |x - y| < 1/3, but if we already know that |x - y| < 1/3 and |y - z| < 1/3 then there is a greater than 5/9 chance that |x - z| < 1/3.  The problem is that I don't know how to figure out exactly what the chance that |x - z| < 1/3 is, which is why I gave up on this approach.


Wrap it in bacon

Offline

#15 2011-12-07 23:05:03

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: probability

hi TheDude,

Thanks for all your help.  I also cannot see how to get round this.  But, oh well, this thread has taught me some new maths. 

Best wishes,   smile

Bob

Last edited by Bob (2011-12-08 06:45:10)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#16 2011-12-08 02:36:25

juantheron
Member
Registered: 2011-10-19
Posts: 312

Re: probability

thanks to all for nice explanation

Offline

Board footer

Powered by FluxBB