Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 30th, 2003, 10:11 AM
Maldor's Avatar
Maldor Maldor is offline
Muhhnnn !!
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2003
Posts: 1,530 Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
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 ?

Reply With Quote
  #2  
Old April 30th, 2003, 04:23 PM
M3xican's Avatar
M3xican M3xican is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Italy -> Naples
Posts: 9 M3xican User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to M3xican
Lightbulb 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

Reply With Quote
  #3  
Old May 1st, 2003, 06:11 PM
balance balance is offline
.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 296 balance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #4  
Old May 5th, 2003, 05:42 AM
Maldor's Avatar
Maldor Maldor is offline
Muhhnnn !!
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2003
Posts: 1,530 Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
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 =)

Reply With Quote
  #5  
Old May 8th, 2003, 09:01 AM
M3xican's Avatar
M3xican M3xican is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Italy -> Naples
Posts: 9 M3xican User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to M3xican
Lightbulb Sorry...

.

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

Reply With Quote
  #6  
Old May 8th, 2003, 11:08 AM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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).

Reply With Quote
  #7  
Old May 8th, 2003, 01:43 PM
balance balance is offline
.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 296 balance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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 01:45 PM.

Reply With Quote
  #8  
Old May 8th, 2003, 03:06 PM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #9  
Old May 9th, 2003, 01:46 AM
Maldor's Avatar
Maldor Maldor is offline
Muhhnnn !!
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2003
Posts: 1,530 Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level)Maldor User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
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


Reply With Quote
  #10  
Old May 9th, 2003, 01:12 PM
balance balance is offline
.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 296 balance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #11  
Old May 9th, 2003, 01:16 PM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #12  
Old May 9th, 2003, 06:00 PM
balance balance is offline
.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 296 balance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
yes, that's what i was meaning. ok, thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > cumulative probability...

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap