The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Random Number Generator

SercoSteveB
Active Participant

Which of the following are possible values of Numeric Value Out following execution of the VI?

 

NOTE: Multiple answers may apply.

 

Random Njumber Generation.png

 

a) -0.213

b) 0

c) 4.5321

d) 10.203

Comments
nik35324
Member

The output of for loop is between 0 and 10 and so the min and max. Subtracting min from max is between 0 and 10. Options A and D can be eliminated.

Answer: B (Unlikely) and C for sure.

Any insights about option B?

Hritzgujarati
Member
Answer is clear.....! C Random number generator will not generate the same number twice in a raw. so there is no chance of generating 10 same number in a raw, So B is not an answer.
crossrulz
Knight of NI

B, C

 

Few comments:

1. The loop cannot output a 10 since the Random Number is not inclusive of 1

2. 0 is technically possible, but the chances are really close to 0.  To be more technical (if I am remembering basic statistic properly), the chances of a number is 1/(2^64).  Now 2 numbers being exactly the same is 1/(2^128).  Now the chances of 10 numbers being the same would be 1/(2^640) = 5.42e-20.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
MrStevenUND
Member

B, C.  However B is highly unlikely...

CataM
NI Employee (retired)

b) and c)

Matt-A.
Member

Agree.  B unlikely, and C is possible

jeeva89
Member

C & D is possible

Hritzgujarati
Member

Jeeva could you please elaborate your answer

Mr._Sri_logeshwaran
Member
C is the Ans. Since Random numbers will generate 0-1 so multiples of 10 will give upto 0-10 values. Also if we subtract Max with Min we will get values 10 or less than 10 so Ans is C
Timsrice
Member

C
A& D are impossible
(and it is not worth waiting for B!)

 

interesting discussions above on how unusual it would be to generate a zero with this.

 

...so, put the snippet in a loop, ran it a million times (because you can) and then simply put the all answers generated on a histogram...
statistics.PNGSo with 10 random numbers in the range 0-10 they stand to be reasonably evenly spread out, so values (amplitude) around 8 and 9 are common.

In one million attempts the lowest value generated was 1.5,

Which I think demonstrates the validity of the statements above that the chances of getting zero are astonishingly small.  

What I hadn't appreciated is how very unlikely it is to get a number below 1.

 

alexderjuengere
Active Participant

my gut feeling was C

 

@ Timsrice:

...so, put the snippet in a loop, ran it a million times (because you can) and then simply put the all answers generated on a histogram

 

I was about to do that  ^^

kudos to you!

 

jwscs
Active Participant

B (extremely unlikely, bc all array elems would have to be the same)

and C

 

not A, because x-z for x>=z can never be negative

not D, because 1*10 is the maximum (after looking up the help on random, this is exclusive, bc random never produces a 1)


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
SercoSteveB
Active Participant

Answer: B & C, nice one all. 

 

Lots of good stuff in this post, thanks.

levonsg
Member

B,C

https://images.youracclaim.com/size/340x340/images/2edb5b1a-9414-44e1-8519-c774fc6dd079/36015_Certificate_Badges_FINAL__1__NI_Instructor_v5.png