Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
April 30th, 2003, 11:11 AM
 Maldor
Muhhnnn !!

Join Date: Apr 2003
Posts: 1,530
Time spent in forums: 1 Week 1 Day 7 h 38 m 2 sec
Reputation Power: 88
cumulative probability...

Here is the problem.

One worker have a probability of 2% to deliver an item each hour.
The aim is to write a function that will calculate how much item would go out from factory during an hour if I have X workers.

Input would be X (number of worker) and a random value that will be compared to probability.

Example:

with 1 worker
0 item => 98%
1 item => 2%

if i call foo(X) 100 times, I will (theorically) get 98 times 0 and 2 times 1.

I actually have this function coded with looping over each worker, it is quite heavy and i would like to find a mathematical way to do it...

Actual function:

ItemAmount = 0
For (worker = 1 to X)
{
RandomValue = Random(0,99)
if (RandomValue < 2)
item++
}
// Quite heavy isn't it ?

#2
April 30th, 2003, 05:23 PM
 M3xican
Junior Member

Join Date: Apr 2003
Location: Italy -> Naples
Posts: 9
Time spent in forums: < 1 sec
Reputation Power: 0
Probability

Hi,
if a worker have a probability of 2% to deliver an item each hour, n workers have a probability of (2*n)% .
Because if every n independent event have a probability P(xi)=a the total probability is
P(X)=P(x1)+P(x2)+...P(xn)=n*a

So your function can be rewritten as:
Code:
```rand_val=rand(0,99);
if(rand_val<=(n*2))
item++;```

Good work

#3
May 1st, 2003, 07:11 PM
 balance
.

Join Date: Dec 2002
Posts: 296
Time spent in forums: < 1 sec
Reputation Power: 11
i'm quite interested in cumalitive probability at the moment. haven't got too far though yet. one useful phrase to look for is 'cumulative poisson'. here's something i found on it. i'm not going to pretend i understand it, but this may or may not be of use to you (free book though) :

6.2 Incomplete Gamma Function, Error
Function, Chi-Square Probability Function,
Cumulative Poisson Function -

http://www.ulib.org/webRoot/Books/N...s/bookcpdf.html

#4
May 5th, 2003, 06:42 AM
 Maldor
Muhhnnn !!

Join Date: Apr 2003
Posts: 1,530
Time spent in forums: 1 Week 1 Day 7 h 38 m 2 sec
Reputation Power: 88
M3xican: They do are independant, but your formula simulation tell me if an item was built or not... I want to know How much items went out of production. Your formula says "At least one item went out".

Balance: Thanks, will take a look...

Others: Question still pending =)

#5
May 8th, 2003, 10:01 AM
 M3xican
Junior Member

Join Date: Apr 2003
Location: Italy -> Naples
Posts: 9
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry...

.

Last edited by M3xican : July 2nd, 2003 at 01:56 PM.

#6
May 8th, 2003, 12:08 PM
 epl
Contributing User

Join Date: Mar 2001
Location: Dublin
Posts: 413
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
M3xican, I don't mean to be rude, but I can't see any basis to your response - it makes no sense. Perhaps you could elaborate on how you came to it.

Balance is correct - use an inverse cumulative poisson function to generate your random value from the uniform value generated by rand(). If my memory serves me right then an inverse cumulative normal / gaussian distribution will also suffice where the number of workers is large enough (>=250 in this case).

#7
May 8th, 2003, 02:43 PM
 balance
.

Join Date: Dec 2002
Posts: 296
Time spent in forums: < 1 sec
Reputation Power: 11
are markov chains even more useful for things like this? i've read a few bits and bobs on probability, and as soon as it gets into cumulative stuff in particular, markov chains seem to get mentioned. again, not going to pretend i actually understand what i'm talking about. would like to though, very much.

Last edited by balance : May 8th, 2003 at 02:45 PM.

#8
May 8th, 2003, 04:06 PM
 epl
Contributing User

Join Date: Mar 2001
Location: Dublin
Posts: 413
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
likewise, i'm no expert but my answer would be no.

as i understand it, markov chains could only apply if the situation being modelled were to involved a sequence of non-independent tests - whereas the question above concerns a collection of simultaneous - and, i would assume, independent - tests.

for example if we modelled not just the increased number of workers but also an increased number of hours, we could modify our binary probability model so that the probability of delivery in a given hour is related to whether delivery was achieved in the previous hour - as might be the case in practise.

i don't know what other conditions would need to be met etc - like i say i'm not an expert

#9
May 9th, 2003, 02:46 AM
 Maldor
Muhhnnn !!

Join Date: Apr 2003
Posts: 1,530
Time spent in forums: 1 Week 1 Day 7 h 38 m 2 sec
Reputation Power: 88
mmmh it seems that I will have to search after my class notes =(
__________________
"The ultimate knowledge is reached when it does not bring new questions..."
-- Usaphdas encyclopedia XV.4

#10
May 9th, 2003, 02:12 PM
 balance
.

Join Date: Dec 2002
Posts: 296
Time spent in forums: < 1 sec
Reputation Power: 11
Quote:
 as i understand it, markov chains could only apply if the situation being modelled were to involved a sequence of non-independent test

would characters from usual text be applicable to that do you think?

#11
May 9th, 2003, 02:16 PM
 epl
Contributing User

Join Date: Mar 2001
Location: Dublin
Posts: 413
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 13
i'm not sure if i get what you mean - but if the probability of a given character "coming next" was dependent on the previous character but independent of it's predecessors then i guess so.

#12
May 9th, 2003, 07:00 PM
 balance
.

Join Date: Dec 2002
Posts: 296
Time spent in forums: < 1 sec
Reputation Power: 11
yes, that's what i was meaning. ok, thanks.

 Viewing: Dev Shed Forums > Programming Languages - More > Software Design > cumulative probability...