> Computers > Programming
Various Topics Home | Disclaimer | Report Adult Posts

Various Topics on Programming



Programming - "find the probability" in Computers


Old 06-16-2007   #1
.... ..r..
 
Default find the probability

A pair of dice is tossed, find the probability of
(i) The sum is even,
(ii) The sum exceeds 9.
Given that the faces appearing are different

 
Old 06-16-2007   #2
..n ..caris..
 
Default Re: find the probability

King imran <imran6286@gmail.com> writes:

> A pair of dice is tossed, find the probability of
> (i) The sum is even,
> (ii) The sum exceeds 9.
> Given that the faces appearing are different


Looks like homework (best done by you) and does not look like
programming so comp.programming is an odd place to post.

--
Ben.
 
Old 06-16-2007   #3
..k..
 
Default Re: find the probability

On Jun 16, 10:26 am, King imran <imran6...@gmail.com> wrote:
> A pair of dice is tossed, find the probability of
> (i) The sum is even,
> (ii) The sum exceeds 9.
> Given that the faces appearing are different


It would be better to post this on the math group, sci.math, instead.
This is for discussing programming computers, not math questions with
no relevance to that.

 
Old 06-16-2007   #4
..ss..
 
Default Re: find the probability

On Sat, 16 Jun 2007 09:26:27 -0700, King imran <imran6286@gmail.com>
wrote:

>A pair of dice is tossed, find the probability of
>(i) The sum is even,
>(ii) The sum exceeds 9.
>Given that the faces appearing are different

My two dice have 4 faces each and are marked 10, 12, 14, 16 and 20,
20, 20, 20 respectively.

(i) 100%
(ii) 100%

Now just let me have your instructor's e-mail address and I can send
in your homework for you.

rossum

 
Old 06-16-2007   #5
..sc.. ..urguign..
 
Default Re: find the probability

King imran <imran6286@gmail.com> writes:

> A pair of dice is tossed, find the probability of
> (i) The sum is even,
> (ii) The sum exceeds 9.
> Given that the faces appearing are different


(loop
:with tries = 1000000
:repeat tries
:for dice-1 = (1+ (random 6))
:for dice-2 = (1+ (random 6))
:when (and (/= dice-1 dice-2) (evenp (+ dice-1 dice-2))) :sum 1 :into evens
:when (and (/= dice-1 dice-2) (< 9 (+ dice-1 dice-2))) :sum 1 :into exceeds
:finally (return (list (/ evens tries) (/ exceeds tries))))
--> (166381/500000 111237/1000000)


--
__Pascal Bourguignon__ http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
 
Old 06-17-2007   #6
..cha.. ..athfie..
 
Default Re: find the probability

King imran said:

> A pair of dice is tossed, find the probability of
> (i) The sum is even,


The probability is 1. A pair is two, so there are two dice, and two is
even.

> (ii) The sum exceeds 9.


The probability is 0. There are only two dice. Two is less than nine.

> Given that the faces appearing are different


That doesn't affect the sum at all. There are still only two dice.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Old 06-17-2007   #7
..n ..a..
 
Default Re: find the probability

Pascal Bourguignon <pjb@informatimago.com> writes:

> King imran <imran6286@gmail.com> writes:
>
>> A pair of dice is tossed, find the probability of
>> (i) The sum is even,
>> (ii) The sum exceeds 9.
>> Given that the faces appearing are different

>
> (loop
> :with tries = 1000000
> :repeat tries
> :for dice-1 = (1+ (random 6))
> :for dice-2 = (1+ (random 6))
> :when (and (/= dice-1 dice-2) (evenp (+ dice-1 dice-2))) :sum 1 :into evens
> :when (and (/= dice-1 dice-2) (< 9 (+ dice-1 dice-2))) :sum 1 :into exceeds
> :finally (return (list (/ evens tries) (/ exceeds tries))))
> --> (166381/500000 111237/1000000)


That's working too hard. Just try all the possibilities. There
are only 36, ***uming conventional 6-sided dice.
--
Ben Pfaff
http://benpfaff.org
 
Old 06-17-2007   #8
..sc.. ..urguign..
 
Default Re: find the probability

Ben Pfaff <blp@cs.stanford.edu> writes:

> Pascal Bourguignon <pjb@informatimago.com> writes:
>
>> King imran <imran6286@gmail.com> writes:
>>
>>> A pair of dice is tossed, find the probability of
>>> (i) The sum is even,
>>> (ii) The sum exceeds 9.
>>> Given that the faces appearing are different

>>
>> (loop
>> :with tries = 1000000
>> :repeat tries
>> :for dice-1 = (1+ (random 6))
>> :for dice-2 = (1+ (random 6))
>> :when (and (/= dice-1 dice-2) (evenp (+ dice-1 dice-2))) :sum 1 :into evens
>> :when (and (/= dice-1 dice-2) (< 9 (+ dice-1 dice-2))) :sum 1 :into exceeds
>> :finally (return (list (/ evens tries) (/ exceeds tries))))
>> --> (166381/500000 111237/1000000)

>
> That's working too hard.


Yes, but that's thinking less, an obvious objective of the OP :-)


> Just try all the possibilities. There
> are only 36, ***uming conventional 6-sided dice.
> --
> Ben Pfaff
> http://benpfaff.org


--
__Pascal Bourguignon__ http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
 
Old 06-17-2007   #9
..r..
 
Default Re: find the probability


"Pascal Bourguignon" <pjb@informatimago.com> wrote in message
news:877iq3joy8.fsf@thal***a.lan.informatimago.com ...
> Ben Pfaff <blp@cs.stanford.edu> writes:
>
>> Pascal Bourguignon <pjb@informatimago.com> writes:
>>
>>> King imran <imran6286@gmail.com> writes:
>>>
>>>> A pair of dice is tossed, find the probability of
>>>> (i) The sum is even,
>>>> (ii) The sum exceeds 9.
>>>> Given that the faces appearing are different
>>>
>>> (loop
>>> :with tries = 1000000
>>> :repeat tries
>>> :for dice-1 = (1+ (random 6))
>>> :for dice-2 = (1+ (random 6))
>>> :when (and (/= dice-1 dice-2) (evenp (+ dice-1 dice-2))) :sum 1 :into
>>> evens
>>> :when (and (/= dice-1 dice-2) (< 9 (+ dice-1 dice-2))) :sum 1 :into
>>> exceeds
>>> :finally (return (list (/ evens tries) (/ exceeds tries))))
>>> --> (166381/500000 111237/1000000)

>>
>> That's working too hard.

>
> Yes, but that's thinking less, an obvious objective of the OP :-)
>
>
>> Just try all the possibilities. There
>> are only 36, ***uming conventional 6-sided dice.


But you are ***uming the intent of the homework. Possibly the intent
was to write a program that enumerates the possibilities and then counts
which of them meet the criteria. Of course there were no specifications
on the dice (or a statement that all rolls are equally probable)
so any answer would be speculative.


 
Old 06-17-2007   #10
..mi..
 
Default Re: find the probability

"Barry" writes:

> "Pascal Bourguignon" <pjb@informatimago.com> wrote in message


>>> Just try all the possibilities. There
>>> are only 36, ***uming conventional 6-sided dice.

>
> But you are ***uming the intent of the homework. Possibly the intent
> was to write a program that enumerates the possibilities and then counts
> which of them meet the criteria. Of course there were no specifications
> on the dice (or a statement that all rolls are equally probable)
> so any answer would be speculative.


The original question was about "a pair of dice".

Most reasonable people would ***ume that the subject was an ordinary pair of
dice. Just as a question containing "The man ran" would imply it was a
one-headed man with two legs. I would hope that the OP has learned his
lesson, do not post questions to a group of programmers, except as a last
resort. .

There was nothing in the OP's post to indicate that a program was involved
in any way. And, indeed, a program would be about the worst possible way to
answer the question. Questions that can be solved analytically should be
solved that way, a simulation program is a last resort when nothing else
works.



 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0