Results 1 to 3 of 3

Thread: Bell Curves

  1. #1

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268

    Question Bell Curves

    I've been struggling with a certain random number-related problem for a while. I need to be able to generate a random number from 0 to 100, weighting the 0 as most likely to occur and 100 least likely. When graphed it should look like half a bell curve, but the problem is that I don't quite know how to do it. I've tried reading up on bell curves, but I'm not exactly a great mathemetician.

    The purpose of this random number generator is to decide upon a single monster in a large database of monsters which are given a rarity level of 0 for most common to 100 for extremely rare. Any help would be greatly appreciated.
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    one way to do this (although might not be useful for trying to make a bell curve):
    make an array called ints:
    ints[0] = 1
    ints[1] = 2
    ints[2] = 3
    ints[3] = 4
    ...
    ints[99] = 100

    Then another array called chance:
    chance[0] = 30
    chance[1] = 20
    chance[2] = 15
    chance[3] = 5
    I think these should add up to 100, but I'm not sure if you have to make it do that.

    then make another array called monster_array
    make the first 30 items in it = 1.
    then the next 20 items 2
    the next 15 = 3
    the next 5 = 4
    etc.



    Thinking about it, to get this to match a bell curve you have to plot a bell curve, note down the y co-ord for the first 100 positive integers then note down those integers into the chance array.

    These will not add up to 100 but I don't think that matters.
    Have I helped you? Please Rate my posts.

  3. #3
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking right...

    It really depends what type you want:

    You could have a binomial distribution - you start at 0, then you stop at that number with a probability of p, otherwise you go to the next number.
    E.g. if you had p = 0.5, then you would have P(number = x) = 2-x-1. This makes each number half as likely as the next.

    OR There are other types of distributions though. You could have a normal distribution with mean zero, s.d. whatever you want, then just ignore all negative values (i.e. run again) and all those > 100 have as =100. This would be harder to code, yet possible. You'd have to account for continuity correction, P(number = x) = P(x - 0.5 < Stat < x + 0.5)

    OR You could have linear degression. P(number = x) = k * p(number = x-1), where a suitable k is found such that the sum of probabilities is = 1.

    OR You could use a cosine wave. Bit trickier, would have to multiply out so you have the sum of probabilities = 1, and spans 0 to 100. Still possible.
    sql_lall

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width