LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Riffle is Biased!

Solved!
Go to solution
Of course riffle does more. Seed input. Index output. A full alternative would need the random signal generation tool.
0 Kudos
Message 11 of 21
(3,007 Views)

OK.  Good idea with the Seed input, here are a couple of VIs.

 

Bad Riffle.vi -> In case there was any lingering doubt that I put my finger on the algorithm and problem with the existing Riffle.vi I have implemented it fully in G using the Uniform White Noise.vi.  Now you can enter a seed value >0 and compare the result with Riffle.vi using the same seed.  QED.

 

Shuffle.llb -> contains a polymorphic vi Shuffle.vi to implement the real Fisher Yates shuffle.  I have included a few more datatypes than Riffle (including string and boolean) just for the heck of it.  Includes the seed and index outputs like Riffle.

 

I call it Shuffle and not Riffle because as near as I can tell the existing Riffle.vi (1) Does not Riffle an array (interleaved shuffle) (2) Does not even do what it says in the Detailed Help (Choose two indices at random and swap them) and most importantly (3) does not properly implement an unbiased shuffle.  Other than that I really like the VI!

Download All
Message 12 of 21
(2,975 Views)

Gosh- Darin--

 

you sound offended! Smiley Very Happy

Of course you are correct. Smiley Mad


"Should be" isn't "Is" -Jay
0 Kudos
Message 13 of 21
(2,940 Views)

@Darin.K wrote:

OK.  Good idea with the Seed input, here are a couple of VIs.



Could you put up some 8.6 versions please? I'd be interested to see.

0 Kudos
Message 14 of 21
(2,938 Views)

@HR: Here is the Shuffle VI in LV8.6.

 

@Jeff - Not offended, the detective work is kind of fun in a way.  However, I was hoping to discover an off by one type error, a bit disappointed that it was the correct implementation of a flawed algorithm instead of the reverse.  It does, for me at least, call into question the other VIs contained in that package.

Message 15 of 21
(2,906 Views)

@Darin.K wrote:

@HR: Here is the Shuffle VI in LV8.6.

 



Thanks

0 Kudos
Message 16 of 21
(2,874 Views)
Solution
Accepted by topic author Darin.K

Darin.K,

 

Great job and good find. Thanks to your efforts this was reported to R&D (# 344833) for further investigation.

 

Thank you for the feedback!

 

Andrew S.

Application Engineering Specialist
National Instruments
Message 17 of 21
(2,862 Views)

Fixed!

 

I cannot find it mentioned in the list of 2012 bug fixes or in the2012 f1 or f2 patche details, but this has apparently been fixed in 2012. 😄

 

If I open the existing VI of the first post here, the riffle VI has an obsolete tag and is named "Riffle (obs 2012).vi" to retain the biased functionality for backward compatibility.

 

Replacing it with the new riffle from the 2012 palette give the correct and expected unbiased result. All's well now! 😄

 

0 Kudos
Message 18 of 21
(2,721 Views)

Awesome!  One down, Avagadro's number to go!

Message 19 of 21
(2,706 Views)

@altenbach wrote:
the riffle VI has an obsolete tag and is named "Riffle (obs 2012).vi" to retain the biased functionality for backward compatibility.

 


 

That's a little interesting to me.  I'd bet almost every person using it wasn't exactly counting on the bias.  I'm not 100% opposed to the resulting fix; in fact I find it a little neat that someone took the time to preserve the biased functionality.

0 Kudos
Message 20 of 21
(2,685 Views)