Results 1 to 3 of 3

Thread: Generating Probability in a sequence

  1. #1
    Newbie
    Joined
    Jan 2017
    From
    Georgia
    Posts
    2

    Question Generating Probability in a sequence

    So I work on my friend's game in my spare time writing quests and events, that sort of thing. I'm working on an event now that has got me stumped trying to work out the probability of results!

    The NPC needs to hand out one of twelve items at a particular frequency when another item is turned into her. The problem is three of them need to occur 20% of the time each, another three 10% each, three more at 2% each, and the last three at 1% each. I know that to have a roughly even chance of each item, the frequencies would need to be set such as:

    ifrand(8) followed by 9, 10, 11, 13, 14, 17, 20, 25, 33, and ending with (50) between the last two. I probably could've figured this one out on my own (this much was in a guide) but twelve instances of 8% is a bit more straightforward than what I need.

    I don't think the code for this allows decimals but even considering integers I find myself thinking in circles! Can anyone help? How would I go about working out more progs like this in the future?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Nov 2013
    From
    California
    Posts
    5,606
    Thanks
    2368

    Re: Generating Probability in a sequence

    I really can't follow what you are saying after the 2nd paragraph.

    you have a random variable that can take 12 values and is distributed as

    $\{0.2, 0.2, 0.2, 0.1, 0.1, 0.1, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01\}$

    right off we have a problem in that the probabilities don't sum to 1, they sum to 0.99

    so we need a distribution of

    $P[k] = \dfrac{1}{0.99} \times \{0.2, 0.2, 0.2, 0.1, 0.1, 0.1, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01\}$

    The way to get this is to use a 99 sided die.

    $1-20 \to \text{item 1}$
    $21-40 \to \text{item 2}$
    $41-60 \to \text{item 3}$
    $61-70 \to \text{item 4}$
    $71-80 \to \text{item 5}$
    $81-90 \to \text{item 6}$
    $91- 92 \to \text{item 7}$
    $93-94 \to \text{item 8}$
    $95-96 \to \text{item 9}$
    $97 \to \text{item 10}$
    $98 \to \text{item 11}$
    $99 \to \text{item 12}$

    You can adjust this easily to use a 99k sided die but if your RNG is truly random (which of course it isn't) this mapping will work fine.

    How you implement this in your game language I leave to you to figure out.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jan 2017
    From
    Georgia
    Posts
    2

    Re: Generating Probability in a sequence

    I don't think my previous reply went through but I believe I figured it out.

    My notes look like nonsense: (I know this placeholder syntax is garbage)
    ifrand(33) mint
    ifrand(61) white
    ifrand(77) pink
    ifrand(66) blue
    else red
    else
    ifrand(50) jawbreaker
    ifrand(61) white
    ifrand(77) pink
    ifrand(66) blue
    else red

    else chocolate
    ifrand(61) white
    ifrand(77) milk
    ifrand(66) dark
    else pepper

    i.e. there's a 33% chance it'll be mint, otherwise it's a jawbreaker or chocolate. If it's a mint, there's a 66% chance it'll be white, if not there's a 77% chance it'll be pink, if not there's a 66% chance it'll be blue, otherwise it'll be red.

    But I think what this structure will do is give a roughly 20% chance of getting White Mint, White Jawbreaker, or White Chocolate; 10% Pink Mint, Pink Jawbreaker, or Milk Chocolate; 2% chance of Blue Mint, Blue Jawbreaker, Dark Chocolate; or 1% chance of Red Mint, Red Jawbreaker, Pepper Chocolate.
    Yes, all this work is to distribute candy prizes.
    It makes sense in the game.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. closed form for sequence z=z^2+c & generating function
    Posted in the Advanced Algebra Forum
    Replies: 1
    Last Post: Oct 4th 2011, 03:05 AM
  2. Generating function for a sequence
    Posted in the Discrete Math Forum
    Replies: 3
    Last Post: Apr 27th 2011, 10:16 AM
  3. Euler numbers generating sequence radius of convergence
    Posted in the Advanced Math Topics Forum
    Replies: 9
    Last Post: Nov 26th 2010, 12:50 AM
  4. generating function for sequence question
    Posted in the Discrete Math Forum
    Replies: 6
    Last Post: Oct 26th 2010, 08:12 AM
  5. generating sequence
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: May 26th 2010, 12:25 PM

/mathhelpforum @mathhelpforum