05-24-2017 03:58 PM
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?
05-24-2017 03:59 PM
Duplicate of https://forums.ni.com/t5/Example-Programs/Simple-Way-to-Randomize-an-Array/ta-p/3509227
Found it.
05-24-2017 07:37 PM - edited 05-24-2017 07:39 PM
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 ...
05-25-2017 07:55 AM
Riffle is the function you seek.
05-25-2017 08:10 AM
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.
05-27-2017 10:07 PM
Are you aware that the word "grok" is, in fact, Martian?
Bob "Little-Known Facts" Schor