Random Number

Chris Davison

MrExcel MVP
Joined
Feb 15, 2002
Messages
1,790
Evening all,

how can I return a single random number from the set : 1 to 10 and 20 to 30

ie

8 would be okay
2 would be okay
23 would be okay
29 would be okay

but 15 would not be okay
and 18 would not be okay

Just one random number from those ranges 1-10, 20-30

I'm pretty familiar with =RAND and also have the Analysis Toolpak installed

many thanks
Chris
:)
 
Eli,

Your first formula (slightly modified here) appears to me elegant and satisficing:

=IF(RANDBETWEEN(0,1),RANDBETWEEN(1,10),RANDBETWEEN(20,30))

The size of <1,10> is eq to that <20,30>. Is there something I'm missing?

Regards,

Aladin

Hi Aladin,
1-10 contains 10 numbers, 10-20 contains 11 numbers, therefore the randomal numbers which is formed by the first formula would be biased so that there will be statistically slightly more numbers between 1-10 than between 20-30.
Do I make myself clear?
Therfore the second suggestiom is making compensation of that.
The exact formula would be:
=if(randbetween(1,21)<=10,randbetween(1,10),randbetween(20,30))
Regards,
Eli
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
On 2002-03-31 09:05, eliW wrote:
Eli,

Your first formula (slightly modified here) appears to me elegant and satisficing:

=IF(RANDBETWEEN(0,1),RANDBETWEEN(1,10),RANDBETWEEN(20,30))

The size of <1,10> is eq to that <20,30>. Is there something I'm missing?

Regards,

Aladin

Hi Aladin,
1-10 contains 10 numbers, 10-20 contains 11 numbers, therefore the randomal numbers which is formed by the first formula would be biased so that there will be statistically slightly more numbers between 1-10 than between 20-30.
Do I make myself clear?
Therfore the second suggestiom is making compensation of that.
The exact formula would be:
=if(randbetween(1,21)<=10,randbetween(1,10),randbetween(20,30))
Regards,
Eli

I was aware of the reason. I thought: "The sizes of intervals are eq -- what is he worried about?" Gee, back to the elementary for me :(.
 
Upvote 0
Hi Aladin..

No just us exceller being difficult AS ALWAYS..

you formua is PERFECTION.. but this is a case of...

6 differen number in one cell, no two the same..

Kinda tough.. Any ideas mate!
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top