Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to generate a list of Random Numbers that are Whole numbers and less than 50. I tried creating numbers but I always get a decimal number.
Can anyone tell me how can I obtain this result?
Thanks.
Multiply the decimal by 50 and then round it.
Hi!
t1:
Load RecNo( ) as A, round(50*rand( ),1) as B autogenerate(50);
May be this:
LOAD Round(Rand() * 49) as RandNum
AutoGenerate 50;
Best,
Sunny
Hi,
Thanks, It worked. I also understood the concept very well.
Thanks.
Cepren solution is good one, but if you need equal probabilities between numbers, and from 1 to 50 you should use something a bit different (i generate 500000 to see the difference):
t1:
Load RecNo( ) as A, round(50*rand( ),1, 0.5)+0.5 as B autogenerate(500000);
If you don't add the offset the first and the last number has half the probabilities than other numbers:
I'm a bit idle today
Hehe.. thanks for explaining the offset part.. I didn't know that.