+ Reply to Thread
Results 1 to 7 of 7

What excel function to use to generate some words with a certain frequency?

  1. #1
    Registered User
    Join Date
    10-01-2008
    Location
    Singapore
    Posts
    1

    What excel function to use to generate some words with a certain frequency?

    What excel function(s) can I use if I want to generate some random words with a certain frequency?

    For example, I want:
    Apple to appear 10% of the time
    Banana to appear 20% of the time
    Cherry to appear 20% of the time
    Dates to appear 50% of the time

    Thank you!

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Distributing text values by percentages

    With
    C1: apple
    D1: banana
    E1: cherry
    F1: dates

    Try this:
    Please Login or Register  to view this content.
    Copy that formula down as far as needed.

    If you use that formula in A1:A2000, these formulas verify the results.

    The count of each item:
    Please Login or Register  to view this content.
    The percentage of C1 (apple):
    Please Login or Register  to view this content.
    Format E1 as %

    Copy those formulas down through Row_4

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Or =INDEX($C$1:$C$4, MATCH(RAND(), {0,0.1,0.3,0.5}, 1))
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Distributing text values by percentages

    Quote Originally Posted by shg View Post
    Or =INDEX($C$1:$C$4, MATCH(RAND(), {0,0.1,0.3,0.5}, 1))
    Wouldn't each of the direct hits for 10%, 30%, and 50% be associated with the next item in the list?

    examples:
    10% would be associated with the 2nd list item, instead of the 1st
    30% would be associated with the 3rd list item, instead of the 2nd
    50% would be associated with the 4th list item, instead of the 3rd

    ...or am I interpreting this wrong?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Match returns the largest value less than or equal to lookup value, so

    RAND() = 0.0 to < 0.1 returns 1
    RAND() = 0.1 to < 0.3 returns 2
    RAND() = 0.3 to < 0.5 returns 3
    RAND() = 0.5 and up returns 4

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Distributing text values by percentages

    Right....so when the RAND function generates 0.1...the 1st list item should be
    selected (since we want 10% of the items to match the 1st list item).

    In this formula, the second item would be returned:
    Please Login or Register  to view this content.
    Consequently, over a large selection the first item's percentage
    would approach....but never reach...10%.

    In this formula:
    Please Login or Register  to view this content.
    The FREQUENCY function performs an upper limit match, so
    • 0-10 would select the 1st item,
    • >10 through 30 would select the 2nd item
    • >30 through 50 would select the 3rd item
    etc

    ...or am I missing something "obvious"? :\

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Consequently, over a large selection the first item's percentage would approach....but never reach...10%.
    Uh-uh.

    Over a large selection, and assuming RAND() returns a reasonably random uniform distribution, the mean percentage of apples will be 10%.
    Last edited by shg; 10-01-2008 at 04:37 PM. Reason: deviation was wrong; pondering

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to start some function between 2 Excel Books?
    By databases1980 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-09-2008, 01:26 AM
  2. Excel Generate List from Multiple Sheets
    By Scorpio in forum Excel General
    Replies: 5
    Last Post: 05-16-2008, 01:20 PM
  3. How to splitt texts into words? (collecting word and compounds)
    By wali in forum Excel Programming / VBA / Macros
    Replies: 53
    Last Post: 02-03-2008, 04:06 AM
  4. Excel function for conversion of figures to words of amounts
    By cooldevil in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-03-2007, 08:16 AM
  5. Excel maro macro to look up a closed excel function workbook.
    By hittingtime in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2006, 10:00 PM

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