+ Reply to Thread
Results 1 to 8 of 8

Random function - weighted

  1. #1
    Periz28
    Guest

    Random function - weighted

    hello,
    I need to do a drawing for a prize and I have a list of 100 names. they are
    in column A. Each person has a different number of points. For each point I
    want the random selection to be weighted.
    So if Tom has 5 points, Jim has 3, and Tammy has 2 then Tom would have 5
    chances to win, Jim 3, and Tammy would have one.
    Here is a sample:
    name Grand Total of all Points
    ralph 16
    tom 10
    **** 9
    harry 8
    jim 2
    jr 2
    mike 2
    mark 1
    robert 1
    tim 1
    In this example, how can Ralph have 16 times greater chance at winning than
    Tim?
    Thanks!


  2. #2
    Ragdyer
    Guest

    Re: Random function - weighted

    I would expand the name list to include duplicates of a name, commensurate
    with the number of points.
    5 Toms
    3 Jims
    2 Tammys
    .... etc.
    --
    HTH,

    RD

    ---------------------------------------------------------------------------
    Please keep all correspondence within the NewsGroup, so all may benefit !
    ---------------------------------------------------------------------------

    "Periz28" <[email protected]> wrote in message
    news:[email protected]...
    > hello,
    > I need to do a drawing for a prize and I have a list of 100 names. they
    > are
    > in column A. Each person has a different number of points. For each
    > point I
    > want the random selection to be weighted.
    > So if Tom has 5 points, Jim has 3, and Tammy has 2 then Tom would have 5
    > chances to win, Jim 3, and Tammy would have one.
    > Here is a sample:
    > name Grand Total of all Points
    > ralph 16
    > tom 10
    > **** 9
    > harry 8
    > jim 2
    > jr 2
    > mike 2
    > mark 1
    > robert 1
    > tim 1
    > In this example, how can Ralph have 16 times greater chance at winning
    > than
    > Tim?
    > Thanks!
    >



  3. #3
    Peri S
    Guest

    Re: Random function - weighted

    I was hoping to avoid that because there are points for each person for each
    month so that would get way up in the thousands...

    "Ragdyer" <[email protected]> wrote in message
    news:[email protected]...
    >I would expand the name list to include duplicates of a name, commensurate
    >with the number of points.
    > 5 Toms
    > 3 Jims
    > 2 Tammys
    > ... etc.
    > --
    > HTH,
    >
    > RD
    >
    > ---------------------------------------------------------------------------
    > Please keep all correspondence within the NewsGroup, so all may benefit !
    > ---------------------------------------------------------------------------
    >
    > "Periz28" <[email protected]> wrote in message
    > news:[email protected]...
    >> hello,
    >> I need to do a drawing for a prize and I have a list of 100 names. they
    >> are
    >> in column A. Each person has a different number of points. For each
    >> point I
    >> want the random selection to be weighted.
    >> So if Tom has 5 points, Jim has 3, and Tammy has 2 then Tom would have 5
    >> chances to win, Jim 3, and Tammy would have one.
    >> Here is a sample:
    >> name Grand Total of all Points
    >> ralph 16
    >> tom 10
    >> **** 9
    >> harry 8
    >> jim 2
    >> jr 2
    >> mike 2
    >> mark 1
    >> robert 1
    >> tim 1
    >> In this example, how can Ralph have 16 times greater chance at winning
    >> than
    >> Tim?
    >> Thanks!
    >>

    >




  4. #4
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    OK, made some modifications but this should do nicely for you. See the instructions in Sheet1

    Random Drawing.zip
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

  5. #5
    Max
    Guest

    Re: Random function - weighted

    >> ... how can Ralph have 16 times greater chance at winning than Tim?

    Try this play as well ..

    Assume the source table is in A1:B11 (headers in row1)

    First, just data > sort the table in ascending order by total points (col
    B), viz.:

    name Grand Total of all Points
    mark 1
    robert 1
    tim 1
    jim 2
    jr 2
    mike 2
    harry 8
    **** 9
    tom 10
    ralph 16

    Then enter a zero in C2
    place in C3: =SUM($B$2:B2)
    Copy C3 down to C12
    (ie copy down by one cell more than the last row in col B)
    Leave C1 empty

    Then, in any empty cell, just put:
    =INDEX(A:A,MATCH(RANDBETWEEN(0,MAX(C:C)),C:C,1))
    to generate the required "weighted" random draw which takes into account the
    commensurate chances by each name's points in col B. This is achieved via col
    C which produces the unique "buckets/tiers" corresponding to the sorted
    points in col B.

    Press F9 to re-generate / re-draw

    Note that RANDBETWEEN requires the Analysis Toolpak to be installed and
    activated. Check the "Analysis Toolpak" box (via Tools > Add-Ins). Chip
    Pearson's page has details on the ATP at:http://www.cpearson.com/excel/ATP.htm
    --
    Max
    Singapore
    http://savefile.com/projects/236895
    xdemechanik
    ---
    "Peri S" wrote:
    > I was hoping to avoid that because there are points for each person for each
    > month so that would get way up in the thousands...
    >
    > "Ragdyer" <[email protected]> wrote in message
    > news:[email protected]...
    > >I would expand the name list to include duplicates of a name, commensurate
    > >with the number of points.
    > > 5 Toms
    > > 3 Jims
    > > 2 Tammys
    > > ... etc.



  6. #6
    Max
    Guest

    Re: Random function - weighted

    Line
    > Then, in any empty cell, just put:


    should have read as:
    > Then, in say, E2:


    Place the draw formula in a cell to the right of the construct ..
    --
    Max
    Singapore
    http://savefile.com/projects/236895
    xdemechanik
    ---

  7. #7
    Peri S
    Guest

    Re: Random function - weighted

    Awesome. You guys are the best. Thank you very much for the help.


    "Max" <[email protected]> wrote in message
    news:[email protected]...
    >>> ... how can Ralph have 16 times greater chance at winning than Tim?

    >
    > Try this play as well ..
    >
    > Assume the source table is in A1:B11 (headers in row1)
    >
    > First, just data > sort the table in ascending order by total points (col
    > B), viz.:
    >
    > name Grand Total of all Points
    > mark 1
    > robert 1
    > tim 1
    > jim 2
    > jr 2
    > mike 2
    > harry 8
    > **** 9
    > tom 10
    > ralph 16
    >
    > Then enter a zero in C2
    > place in C3: =SUM($B$2:B2)
    > Copy C3 down to C12
    > (ie copy down by one cell more than the last row in col B)
    > Leave C1 empty
    >
    > Then, in any empty cell, just put:
    > =INDEX(A:A,MATCH(RANDBETWEEN(0,MAX(C:C)),C:C,1))
    > to generate the required "weighted" random draw which takes into account
    > the
    > commensurate chances by each name's points in col B. This is achieved via
    > col
    > C which produces the unique "buckets/tiers" corresponding to the sorted
    > points in col B.
    >
    > Press F9 to re-generate / re-draw
    >
    > Note that RANDBETWEEN requires the Analysis Toolpak to be installed and
    > activated. Check the "Analysis Toolpak" box (via Tools > Add-Ins). Chip
    > Pearson's page has details on the ATP
    > at:http://www.cpearson.com/excel/ATP.htm
    > --
    > Max
    > Singapore
    > http://savefile.com/projects/236895
    > xdemechanik
    > ---
    > "Peri S" wrote:
    >> I was hoping to avoid that because there are points for each person for
    >> each
    >> month so that would get way up in the thousands...
    >>
    >> "Ragdyer" <[email protected]> wrote in message
    >> news:[email protected]...
    >> >I would expand the name list to include duplicates of a name,
    >> >commensurate
    >> >with the number of points.
    >> > 5 Toms
    >> > 3 Jims
    >> > 2 Tammys
    >> > ... etc.

    >




  8. #8
    Max
    Guest

    Re: Random function - weighted

    You're welcome!
    Thanks for the feedback ..
    --
    Max
    Singapore
    http://savefile.com/projects/236895
    xdemechanik
    ---
    "Peri S" wrote:
    > Awesome. You guys are the best. Thank you very much for the help.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1