Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 07-31-2004, 02:05 AM   #1 (permalink)
 
Newb Techie

Join Date: Jul 2004

Posts: 4

niea_7

Default Another C problem..

I am to developing this C program.Here's the question...

A commuter drives to work each morning. The route he takes each day includes eight stoplights. Most of the times, he has to stop for a red light at two of these stoplights and these stoplights are independent. What is the distribution for the number of times he must stop for a red light on his way to work? What is the probability that he does not have to stop for a red light? What if it is at most 5 times?

I mean..where do i have to start?..what function do i have to use? someone can guide me?? thanks..
niea_7 is offline  
Old 08-03-2004, 03:37 PM   #2 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

That's all they gave you to work off of? It looks more like a math question than a C question...heh
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 08-03-2004, 04:31 PM   #3 (permalink)
 
True Techie

Join Date: Jul 2004

Posts: 217

NeoNemesis

Send a message via AIM to NeoNemesis
Default

yes But i believe he was asking for an answer....
__________________
<font size=\"4\" <a href=\"http://s7.invisionfree.com/NeoForum/index.php\">My Forum</a>
we are just starting out so we need you to join!
NeoNemesis is offline  
Old 08-03-2004, 07:32 PM   #4 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

Too bad I don't know one
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 08-08-2004, 06:58 PM   #5 (permalink)
 
Newb Techie

Join Date: Aug 2004

Posts: 24

amnesty_puppy

Default

Since the events are mutually exclusive/independant the you can use a binomial distribution, this is A level maths which I just did the exam for. (Grabbing pencil and paper) This is probably too late for an answer but I can't resist the challenge of rembering maths from an exam I've done twice:

Let X be the number of times he must stop at a red light. The probability of stopping at a red light is 2/8.

Then X is binomially distributed, where the number of events is 8 and the probability of a success is 2/8.
Maths Notation: X ~ B (8, 2/8)

Therefore the probability of (X = 0) = 8C0 x 2/8^0 x 6/8^8
i.e The probability of not hitting a red light to the power of the number of times, multiplied by the number of ways it can happen (8C0 = 1, all the same outcome can only be arranged once way)

The probability of (X < 6) = . Well this is where I look in the formula booklet which would have this probability listed... oddly it's not within an arms reach.

Anyway, to implement this in C I wouldn't be suprised if there was already some code to work with this kind of maths. Alternatively the only thing here which I would have put in a calculator is 8C0 which has it's own formula, something to do with factorials which you can find on the net.

Well that was a whole lotta fun and not a lot of help I suppose.
amnesty_puppy is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On