LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

discrete index sampling without replacement

I have a vector of values, and I want to uniformly randomly reorder them.

 

in R, the command to do that is "sample". 

 

How do we do that in LabVIEW?

0 Kudos
Message 1 of 6
(2,490 Views)

This is an excellent homework problem.  There is (a) Good Way to do this, and multiple "not-too-bad" ways to do this.

 

Suppose I gave you a set of playing cards and asked you to "uniformly randomly reorder them".  What would you do?  What is the "common name" (for Extra Credit) for this operation?

 

The problem of "random reordering" will boil down (at some level) to "Pick a random integer between 1 and N".  If you've learned about sub-VIs, this is an excellent sub-VI for you to write as part of your solution to this problem.  Now all you have to do is wrap this in an appropriate Loop structure (why a loop?) and let it run.

 

Post your VI when you've finished.  I'll award a Gold Star (a.k.a. a Kudo) if you've chosen the (provably) optimal algorithm ...

 

Bob Schor

 

P.S. -- only the Original Poster is qualified to get the Gold Star.  Please let this fine Engineering Student have "first crack" at this ...

0 Kudos
Message 3 of 6
(2,453 Views)

Riffle is the function you seek.

 

 

0 Kudos
Message 4 of 6
(2,426 Views)

You saw my post.  I found the built-in.  I am likely going to try and do as Bob suggested.  I like trying to do things myself for the first time.  If I invent the wheel on my own, I grok it, instead of remembering what I heard.  I like grokking the fundamentals, it is a strategic strength, and can be a superpower.

0 Kudos
Message 5 of 6
(2,423 Views)

Are you aware that the word "grok" is, in fact, Martian?

 

Bob "Little-Known Facts" Schor

Message 6 of 6
(2,403 Views)