Search
Code Directory
 ASP
 ASP.NET
 C/C++
 CFML
 CGI/PERL
 Delphi
 Development
 Flash
 HTML
 Java
 JavaScript
 Pascal
 PHP
 Python
 SQL
 Tools
 Visual Basic & VB.NET
 XML
New Code
Uber App Clone 1.0
TeeChart NET for Xamarin.Forms 2017
JavaScript Framework Shield UI 1.7.33
SentiVeillance SDK Trial 6.0.171442
Instacart Clone 1.0
Dynamic Product Options for Magento 2 2.3.0
AnyChart JS Charts and Dashboards 8.0.0
Key Transformation 8.1131
AnyGantt JS Gantt Charts 8.0.0
Hex Comparison 5.12
SecureBridge 8.1
Hotelline PMS 1.0
TeeBI for RAD Studio Suite 2017
AnyStock Stock and Financial JS Charts 8.0.0
Entrepreneur News Portal 1.0.2
Top Code
Portfolio Optimizer Tool 1.0
Using MATLAB to Develop Portfolio Optimization Models 1.0
VintaSoft Twain .NET SDK 10.2.0.1
PlaySMS 0.1
Trading Software 1.2.4
Traveling Salesman Problem (TSP) using Simulated Annealing 1.0
iScripts SupportDesk 2.5
PortVaR 1.0
MLM Software ONE 1.5.46
Newest MySQL manual in HTML Help (.chm) 4.1.1-alpha
Wiener filter for Noise Reduction and speech enhancement 1.0
MLM Network 7.0
sun_position.m 1.0
2-3 Tree
Plexum Professional - MLM Software 7.0
Top Rated
Jango Clone Script 1.0
Get Random Record Based on Weight 1.0.0
Travel Portal Script 9.29
Magento Product Designer 1.0
OFOS - Just Eat Clone Script 1.0
PrestaShop Upload Images Module 1.2.1
Trading Software 1.2.4
ADO.NET Provider for ExactTarget 1.0
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Sine Wave Using JavaFX 1.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
Shuffle (Sripts) 1.0
File ID: 85036






Shuffle (Sripts) 1.0
Download Shuffle (Sripts) 1.0http://www.mathworks.comReport Error Link
License: Shareware
File Size: 20.5 KB
Downloads: 11
Submit Rating:
Shuffle (Sripts) 1.0 Description
Description: Shuffle - Random permutation of array elements

This function is equivalent to X(RANDPERM(LENGTH(X)), but 50% to 85% faster. It uses D.E. Knuth's shuffle algorithm (also called Fisher-Yates) and the cute KISS random number generator (G. Marsaglia). While RANDPERM needs 2*LENGTH(X)*8 bytes as temporary memory, SHUFFLE needs just a fixed small number of bytes.

1. Inplace shuffling: Y = Shuffle(X, Dim)
INPUT:
X: DOUBLE, SINGLE, CHAR, LOGICAL, (U)INT64/32/16/8 array.
Dim: Dimension to operate on. Optional, default: 1st non-singleton dimension.
OUTPUT:
Y: Array of same type and size as X with shuffled elements.

2. Create a shuffle index: Index = Shuffle(N, 'index', NOut)
This is equivalent to Matlab's RANDPERM, but much faster, if N is large and NOut is small.
INPUT:
N: Integer number.
NOut: The number of output elements. Optional, default: N.
OUTPUT:
Index: [1:NOut] elements of shuffled [1:N] vector in the smallest possible integer type.

3. Derangement index:
Index = Shuffle(N, 'derange', NOut)
Equivalent to the index method, but all Index[i] ~= i. A rejection method is used: Create an index vector until a derangement is gained.

EXAMPLES:
R = Shuffle(1:8) % [8, 1, 2, 6, 4, 3, 5, 7]
R = Shuffle('abcdefg') % 'efbadcg'
R = Shuffle([1:4; 5:8], 2) % [3, 2, 1, 4; 6, 8, 7, 5]
I = Shuffle(8, 'index'); % UINT8([1, 5, 7, 6, 2, 3, 4, 8])
Choose 10 different rows from a 1000 x 100 matrix:
X = rand(1000, 100); Y = X(Shuffle(1000, 'index', 10), :);
Operate on cells or complex arrays:
C = {9, 's', 1:5}; SC = C(Shuffle(numel(C), 'index'));
M = rand(3) + i * rand(3); SM = M(:, Shuffle(size(C, 2), 'index'))

NOTES: There are several other shuffle functions in the FEX. Some use Knuth's method also, some call RANDPERM. This implementation is faster due to calling a compiled MEX file and it has a smaller memory footprint. The KISS random numbers are much better than the RAND() of the C-standard libs.

Run the unit-test TestShuffle to test validity and speed (see screenshot).
Tested: Matlab 6.5, 7.7, 7.8, 32bit, WinXP,
Compiler: LCC 2.4/3.8, BCC 5.5, Open Watcom 1.8, MSVC 2008.
Compatibility to 64 bit, Linux and Mac is assumed.
Pre-compiled Mex: http://www.n-simon.de/mex

License: Shareware

Related: Matrix, rand, choose, shuffle, uint, xshuffle, operate, cshufflenumelc

O/S:BSD, Linux, Solaris, Mac OS X

File Size: 20.5 KB

Downloads: 11



More Similar Code

With Animated Shuffle Menu you can implement a navigation menu of two levels in your webpage. The applet can display menus in which the selected menu item whizzes to the top of the list and its sub menu items are displayed. The speed of the animation, foreground color, background color, button color, button size, space between buttons etc. of the applet are customizable. The applet also supports curved edge or rectangular buttons. The applet...



You can shuffle your photo/image around and bring each photo into view using shuffle effect. Creation of beautiful image slideshows is possible with this script. Downloadable, simple and easy to use script.



Simple Shuffle Transition Effect Slideshow Script using JQuery. Give beautiful shuffle effect to your images using this script.



This recipe solves the problem of shuffle-merging files -- interlacing (shuffle-merging) many small text files into one large text file, while preserving the order of the lines from within the small files.



Randomly shuffle elements of an array



Shuffle feature implemented, up & down buttons added.



The sripts may be included in a website to offer the oportunity to chat with a visitor, to send him to selected pages. Using phrases speeds up communication.



This Flash effect will "shuffle" each of your messages letters. You can set texts, text colors, fonts, font sizes and font alignment. You can set the delay for the appearance between letters. A background image can be added.



You can shuffle your photo/image around and bring each photo into view using shuffle effect. Creation of beautiful image slideshows is possible with this script. Downloadable, simple and easy to use script



A quick and simple solution for creating an online quiz. It supports unlimited questions, choices, quizzes and the ability to randomly shuffle questions and choices.

User Review for Shuffle (Sripts)
- required fields
     

Please enter text on the image