#1
  1. Muhhnnn !!
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2003
    Posts
    1,530
    Rep Power
    89

    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. #2
  3. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Italy -> Naples
    Posts
    9
    Rep Power
    0

    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
  4. #3
  5. No Profile Picture
    .
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    296
    Rep Power
    12
    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/Nu.../bookcpdf.html
  6. #4
  7. Muhhnnn !!
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2003
    Posts
    1,530
    Rep Power
    89
    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 =)
  8. #5
  9. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Italy -> Naples
    Posts
    9
    Rep Power
    0

    Lightbulb Sorry...


    .
    Last edited by M3xican; July 2nd, 2003 at 12:56 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    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).
  12. #7
  13. No Profile Picture
    .
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    296
    Rep Power
    12
    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.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    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
  16. #9
  17. Muhhnnn !!
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2003
    Posts
    1,530
    Rep Power
    89
    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

  18. #10
  19. No Profile Picture
    .
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    296
    Rep Power
    12
    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?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    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.
  22. #12
  23. No Profile Picture
    .
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    296
    Rep Power
    12
    yes, that's what i was meaning. ok, thanks.

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo