Jump to content

Randomise Array


gobeirne

Recommended Posts

Windows: click on the window that you want an image of and press Alt+PrintScrn - this'll put a screen shot of the selected window on to your clipboard and then you can paste it into your favorite image editing / saving tool.

Or alternatively select the code portion you want and copy it to clipboard with <CTRL>+<C>.

Cheers :beer:

Link to comment
  • 1 month later...
...in this case, using the third method in 7.0 with an array of 10,000 elements leaves 1300-1400 of the elements in their original locations, which is a rather large margin of error (13 percent). Since this method is based on the random number generator and the number is around this range every time I run the VI it seems reasonable to assume that this is a property of the random number generation which is reflected through using this method.
I asked the cryptographer friend I mentioned about this and he provided me an explanation which shows that this is not LV's fault. He said that we can discard the number of times an element is switched more than once back to its original position as statistically insignificant and just look at the number of elements which were never moved.

Then, he said that the formula for calculating the chance of an element not being chosen was defined as

post-1431-1150122432.png?width=400

which means that the larger n gets, the closer the result is to e^-1. Then, he said that the chance of a single element of our array NOT being chosen is ((x-1)/x)^2x (it can be chosen once in each selection and we select 2x numbers because we select 2 random elements in each iteration.

He also said that the formula shown earlier only gets to e at infinity, but it gets very close to e at a very early stage, so basically that equation will be very close to e for any number above a certain number (let's say 20 or 30). With some simple power math he showed that the expression I wrote is equal to e to the power of -2 which comes out to 0.136, which is the result I got and means that LV's random function is now cleared.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.