+ Reply to Thread
Results 1 to 11 of 11

Generate Random Integers

  1. #1
    Registered User
    Join Date
    05-10-2018
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    6

    Generate Random Integers

    Formula for column with the numbers 1 to 70, in a random sequence with 1 repeats of numbers

    Create a table of random numbers with columns 2 and 50 rows.
    Randomly select each value within this range: From 1 to 70
    Column A must be lower than column B

    # A B
    1 37 63
    2 36 52
    3 3 11
    4 48 45
    5 38 40
    6 10 20
    7 24 50
    8 56 63
    9 1 3
    10 23 35
    11 27 45
    12 3 56
    13 20 21
    14 11 31
    15 5 7
    16 16 51
    17 9 46
    18 33 66
    19 60 68
    20 51 58
    21 28 38
    22 10 43
    23 4 7
    24 44 70
    25 56 70
    26 18 67
    27 41 47
    28 4 64
    29 10 11
    30 47 9
    31 23 69
    32 23 40
    33 7 61
    34 2 50
    35 31 64
    36 22 45
    37 19 70
    38 32 55
    39 9 47
    40 31 43
    41 52 70
    42 13 70
    43 31 47
    44 16 60
    45 4 62
    46 18 39
    47 24 69
    48 26 32
    49 47 57
    50 25 42

    Thank you in advance, Any suggestions would be helpful.

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Generate Random Integers

    Hello and welcome to the forum.

    Try this:

    B1 =RANDBETWEEN(2,70)
    A1 =RANDBETWEEN(1,B1-1)

    Drag down both through row 50.

  3. #3
    Registered User
    Join Date
    05-10-2018
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    6

    Re: Generate Random Integers

    Wow Thank you

  4. #4
    Registered User
    Join Date
    05-10-2018
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    6

    Re: Generate Random Integers

    Is there a way that column A and B has 1 duplicate numbers only? like in this sample below values i put 1 to 10

    # A B
    1 3 10
    2 5 6
    3 3 8
    4 2 4
    5 1 9
    6 7 9
    7 5 6
    8 2 10
    9 1 8
    10 4 7
    Last edited by DarkCure; 05-10-2018 at 03:40 PM.

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Generate Random Integers

    Quote Originally Posted by DarkCure View Post
    Wow Thank you
    You're welcome. Thanks for the rep!

    Is there a way that column A and B has 1 duplicate numbers only?
    Maybe, but not that I am aware of.

  6. #6
    Registered User
    Join Date
    05-10-2018
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    6
    Quote Originally Posted by 63falcondude View Post
    You're welcome. Thanks for the rep!


    Maybe, but not that I am aware of.
    Hopefully might be somebody help for formula for that

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Generate Random Integers

    I am not sure what you mean by "1 duplicate only". Assuming that you want a list of random numbers where each value appears no more than twice, I tried this "iterative" technique:

    1) Generate 50 random numbers between 1 and 70. In A1, enter =RANDBETWEEN(1,70) -- copy down to A50
    2) Count duplicates in column B. B1 =COUNTIFS(A$1:A1,A1). Copy down to B50.
    3) Generate an alternate random number for those that are duplicated too many times. C1 =RANDBETWEEN(1,70) [a copy of A1].
    4) Combine list into new list. D1 =IF(B1>2,C1,A1)
    5) Check for duplicates in new list. E1 =COUNTIFS(D$1:D1,D1) [a copy of B1].
    6) Generate another alternate random number in column F. F1 =RANDBETWEEN(1,70) [a copy of A1].
    7) In column G, combine lists G1 =IF(E1>2,F1,D1) [a copy of D1].

    Testing it in my spreadsheet, 3 "iterations" never had a value appear more than twice. The random nature of the algorithm suggests that the probability of the third iteration having a value appear more than twice is not 0, so one would need to test this enough to know how many iterations are needed to be confident enough that it will not generate a list of random numbers where one number appears more than twice. If you pay attention to relative and absolute references, additional iterations can be achieved by continuing to copy the groups of 3 columns across.

    Did I understand correctly?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  8. #8
    Registered User
    Join Date
    05-10-2018
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    6

    Re: Generate Random Integers

    Thank you for immediate response, I do learned a lot from you regarding iterative technique.

    This is my project i working on. I don't know if its called generate "random" sequence of numbers or generate sequence of numbers.

    In this sample of below would like to seek formula for as follows;

    *=C2:F24 are the range of cells that create sequence of numbers
    *Column C to F must have order number (smaller to higher), C is smaller until F is higher number randomly.
    *List of number appear no more than twice.
    *Column G to I is difference of between the number on column C to F, That will generate a random pairing of numbers in (C2,D2 and E2 whose sum is in G2,H2 and I2).

    TestSequencing.xls
    TestSequencing.xlsx
    Attached Images Attached Images
    Last edited by DarkCure; 05-12-2018 at 05:31 PM.

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Generate Random Integers

    I'm still not sure I understand. Looking at your latest sample, I wonder if it is necessary to generate the random numbers in C2:F2? My first thought is that it might be easier to generate the differences (G:I) randomly, then compute the sequence (C:F) from the random differences:

    1) Generate a random starting number in C2 =RANDBETWEEN(1:15) I am guessing at the lower and upper limits here.
    2) Generate a random difference in G2 =RANDBETWEEN(5,20). Again, I am just guessing what the lower and upper limits ought to be. Copy G2 across to I2.
    3) D2 becomes =C2+G2, copy across to F2
    4) Select C2:I2 and copy down to row 24.

    I don't see a ready way to prevent a sequence from occurring more than twice, so one would need to count each sequence of numbers, test if any of the sequences occur more than twice, then replace any such sequences with a new sequence. Test again, until all sequences occur no more than twice.

    Is that an allowed algorithm? Will it have the correct properties and distribution?

  10. #10
    Registered User
    Join Date
    05-10-2018
    Location
    Singapore
    MS-Off Ver
    2016
    Posts
    6

    Re: Generate Random Integers

    Thank you..yes it is allowed algorithm

    Ive been trying your latest formula

    In number 1 C2 =RANDBETWEEN(1:15) or =RANDBETWEEN(1,15)? "you entered few arguments for this action"

  11. #11
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Generate Random Integers

    Yes, that was my type. It should be RANDBETWEEN(1,15).

+ 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. Random, but not quite random... I'd like to generate combos with set rules...
    By LottoLinks in forum Excel Formulas & Functions
    Replies: 38
    Last Post: 01-05-2019, 08:46 PM
  2. [SOLVED] Generate random 6-16-byte random hexadecimal number
    By jsamuelshn in forum Excel General
    Replies: 6
    Last Post: 07-20-2012, 10:38 AM
  3. Autofill range with random integers between two cells
    By Walter01 in forum Excel General
    Replies: 3
    Last Post: 05-29-2012, 01:57 PM
  4. Autofill range with random integers between two values
    By kryten68@googlemail. in forum Excel General
    Replies: 1
    Last Post: 03-15-2012, 05:33 PM
  5. how to generate set of combinations from n-integers in excel/vba
    By alina in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2011, 03:52 PM
  6. Random selection from a series of integers
    By damiandd1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-03-2008, 03:35 PM
  7. generate a random number and use if function to generate new data
    By Dogdoc1142 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2006, 10:50 PM

Tags for this Thread

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