Posted: Sat Sep 04, 2004 1:00 am Post subject: A 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.. _________________ Free MusicCpopServer Definition
Last edited by Jon on Sat Sep 04, 2004 1:20 am; edited 1 time in total
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/
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. _________________ White Papers
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum