Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Restricting a Random Query?

I'm having a little trouble with the random function.

In the first line, I want a random integer between 1 through 4, easy enough.

In the second line, and every line thereafter, I want a random integer 1 through 4... however, I do not want an 'opposing number'. I can roll 1 twice in a row, but if I roll '1' I cannot roll '2', and vice versa. 3 and 4 are also opposites.

Help?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 143
Default Restricting a Random Query?

Define "opposite"
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 153
Default Restricting a Random Query?

I'm having a little trouble with the random function.

In the first line, I want a random integer between 1 through 4, easy
enough.

In the second line, and every line thereafter, I want a random integer 1
through 4... however, I do not want an 'opposing number'. I can roll 1
twice in a row, but if I roll '1' I cannot roll '2', and vice versa. 3
and 4 are also opposites.


I put these constants in B1:E3 to help:
1 2 1 1
3 3 2 2
4 4 3 4
The first of these columns has the acceptable values that aren't opposite "1".
The second of these aren't opposite "2", etc.

In A1, I put
=RANDBETWEEN(1,4)

In A2, I put
=OFFSET(A$1,RANDBETWEEN(0,2),A1)
and copied this formula down column A. This chooses an acceptable value at random from the correct column as determined by the preceding value.

It seems to work, if I understand the problem.

Hope this helps.
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 153
Default Restricting a Random Query?

I put these constants in B1:E3 to help:
1 2 1 1
3 3 2 2
4 4 3 4
The first of these columns has the acceptable values that aren't opposite "1".
The second of these aren't opposite "2", etc.

In A1, I put
=RANDBETWEEN(1,4)

In A2, I put
=OFFSET(A$1,RANDBETWEEN(0,2),A1)
and copied this formula down column A.


We can do without the 3x4 table of helper constants.

Using the same logic, it's enough to put in A1:
=RANDBETWEEN(1,4)
then put in B1
=CHOOSE(3*A1-RANDBETWEEN(0,2),1,3,4,2,3,4,1,2,3,1,2,4)
and copy down.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have a query about loops and random numbers scubadiver Excel Programming 2 December 12th 07 04:19 PM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM
Excel random sorting query fingers Excel Programming 10 January 2nd 04 01:01 AM


All times are GMT +1. The time now is 03:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"