ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_arrayShuffle::getShuffled Interface Reference

Perform an unbiased random shuffling of the input array, known as the Knuth or Fisher-Yates shuffle, and generate and return the new reshuffled array. More...

Detailed Description

Perform an unbiased random shuffling of the input array, known as the Knuth or Fisher-Yates shuffle, and generate and return the new reshuffled array.

Parameters
[in]array: The input contiguous array of shape (:) of either
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU),
  2. type logical of kind any supported by the processor (e.g., LK),
  3. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
  4. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
  5. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
  6. type css_pdt,
  7. type css_type,
or,
  1. a scalar assumed-length character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU),
whose elements will be shuffled uniformly-randomly in the output arrayShuffled on return.
[in]count: The input positive scalar integer of default kind IK, containing the number of elements of the unique uniformly-random draws (shuffled elements) from the input array.
The specified count must not be larger than the length of the input sequence array.
(optional, default = len(array) for scalar character input array, otherwise size(array).)
Returns
arrayShuffled : The output allocatable object of the same type, kind, rank, and shape as the input array of size (1:count) whose elements are set from the randomly-shuffled elements of array.


Possible calling interfaces

arrayShuffled = getShuffled(array, count = count)
Perform an unbiased random shuffling of the input array, known as the Knuth or Fisher-Yates shuffle,...
This module contains procedures and generic interfaces for shuffling arrays of various types.
Warning
The condition 0 <= count must hold for the corresponding input arguments.
The condition count <= lenArray must hold for the corresponding input arguments where lenArray represents the length of the input sequence.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
Remarks
The procedures under discussion are impure.
The procedures under this generic interface provide only a convenient functional interface to shuffling arrays.
For high performance applications, use the subroutine interface setShuffled.
See also
getChoice
setChoice
setShuffled
getRemapped
setRemapped
getReversed
setReversed


Example usage

1program example
2
3 use pm_kind, only: LK ! All kinds are supported.
4 use pm_kind, only: SK ! All kinds are supported.
5 use pm_kind, only: IK ! All kinds are supported.
6 use pm_kind, only: CK ! All kinds are supported.
7 use pm_kind, only: RK ! All kinds are supported.
8 use pm_io, only: display_type
9 use pm_arrayRange, only: getRange
10 use pm_distUnif, only: getUnifRand
12
13 implicit none
14
15 integer(IK) :: count, itry, ntry = 10
16 type(display_type) :: disp
17 disp = display_type(file = "main.out.F90")
18
19 block
20 character(:), allocatable :: array
21 do itry = 1, ntry
22
23 call disp%skip
24 call disp%show("count = getUnifRand(4, 10)")
25 count = getUnifRand(4, 10)
26 call disp%show("array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.")
27 array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
28 call disp%show("array")
29 call disp%show( array, deliml = SK_"""" )
30 call disp%show("array = getShuffled(array)")
31 array = getShuffled(array)
32 call disp%show("array")
33 call disp%show( array, deliml = SK_"""" )
34 call disp%show("count = getUnifRand(0, len(array))")
35 count = getUnifRand(0, len(array))
36 call disp%show("count")
37 call disp%show( count )
38 call disp%show("array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.")
39 array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
40 call disp%show("array")
41 call disp%show( array, deliml = SK_"""" )
42
43 end do
44 end block
45
46 block
47 character(2), allocatable :: array(:)
48 do itry = 1, ntry
49
50 call disp%skip
51 call disp%show("count = getUnifRand(4, 10)")
52 count = getUnifRand(4, 10)
53 call disp%show("array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.")
54 array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
55 call disp%show("array")
56 call disp%show( array, deliml = SK_"""" )
57 call disp%show("array = getShuffled(array)")
58 array = getShuffled(array)
59 call disp%show("array")
60 call disp%show( array, deliml = SK_"""" )
61 call disp%show("count = getUnifRand(0, size(array))")
62 count = getUnifRand(0, size(array))
63 call disp%show("count")
64 call disp%show( count )
65 call disp%show("array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.")
66 array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
67 call disp%show("array")
68 call disp%show( array, deliml = SK_"""" )
69
70 end do
71 end block
72
73 block
74 integer, allocatable :: array(:)
75 do itry = 1, ntry
76
77 call disp%skip
78 call disp%show("count = getUnifRand(4, 10)")
79 count = getUnifRand(4, 10)
80 call disp%show("array = getUnifRand(0, 9, count) ! generate random array for illustration.")
81 array = getUnifRand(0, 9, count) ! generate random array for illustration.
82 call disp%show("array")
83 call disp%show( array )
84 call disp%show("array = getShuffled(array)")
85 array = getShuffled(array)
86 call disp%show("array")
87 call disp%show( array )
88 call disp%show("count = getUnifRand(0, size(array))")
89 count = getUnifRand(0, size(array))
90 call disp%show("count")
91 call disp%show( count )
92 call disp%show("array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.")
93 array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
94 call disp%show("array")
95 call disp%show( array )
96
97 end do
98 end block
99
100 block
101 logical, allocatable :: array(:)
102 do itry = 1, ntry
103
104 call disp%skip
105 call disp%show("count = getUnifRand(4, 10)")
106 count = getUnifRand(4, 10)
107 call disp%show("array = getUnifRand(.false., .true., count) ! generate random array for illustration.")
108 array = getUnifRand(.false., .true., count) ! generate random array for illustration.
109 call disp%show("array")
110 call disp%show( array )
111 call disp%show("array = getShuffled(array)")
112 array = getShuffled(array)
113 call disp%show("array")
114 call disp%show( array )
115 call disp%show("count = getUnifRand(0, size(array))")
116 count = getUnifRand(0, size(array))
117 call disp%show("count")
118 call disp%show( count )
119 call disp%show("array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.")
120 array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
121 call disp%show("array")
122 call disp%show( array )
123
124 end do
125 end block
126
127 block
128 complex, allocatable :: array(:)
129 do itry = 1, ntry
130
131 call disp%skip
132 call disp%show("count = getUnifRand(4, 10)")
133 count = getUnifRand(4, 10)
134 call disp%show("array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.")
135 array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
136 call disp%show("array")
137 call disp%show( array )
138 call disp%show("array = getShuffled(array)")
139 array = getShuffled(array)
140 call disp%show("array")
141 call disp%show( array )
142 call disp%show("count = getUnifRand(0, size(array))")
143 count = getUnifRand(0, size(array))
144 call disp%show("count")
145 call disp%show( count )
146 call disp%show("array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.")
147 array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
148 call disp%show("array")
149 call disp%show( array )
150
151 end do
152 end block
153
154 block
155 real, allocatable :: array(:)
156 do itry = 1, ntry
157
158 call disp%skip
159 call disp%show("count = getUnifRand(4, 10)")
160 count = getUnifRand(4, 10)
161 call disp%show("array = getUnifRand(0., 1., count) ! generate random array for illustration.")
162 array = getUnifRand(0., 1., count) ! generate random array for illustration.
163 call disp%show("array")
164 call disp%show( array )
165 call disp%show("array = getShuffled(array)")
166 array = getShuffled(array)
167 call disp%show("array")
168 call disp%show( array )
169 call disp%show("count = getUnifRand(0, size(array))")
170 count = getUnifRand(0, size(array))
171 call disp%show("count")
172 call disp%show( count )
173 call disp%show("array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.")
174 array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
175 call disp%show("array")
176 call disp%show( array )
177
178 end do
179 end block
180
181end program example
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains procedures and generic interfaces for generating ranges of discrete character,...
This module contains classes and procedures for computing various statistical quantities related to t...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter CK
The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in C-Fortran I...
Definition: pm_kind.F90:542
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2count = getUnifRand(4, 10)
3array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
4array
5"BMJKAXWTNK"
6array = getShuffled(array)
7array
8"BWTKJMNKXA"
9count = getUnifRand(0, len(array))
10count
11+4
12array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
13array
14"TXWB"
15
16count = getUnifRand(4, 10)
17array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
18array
19"PWNPZNC"
20array = getShuffled(array)
21array
22"PZWNPCN"
23count = getUnifRand(0, len(array))
24count
25+3
26array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
27array
28"PNW"
29
30count = getUnifRand(4, 10)
31array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
32array
33"HDGWBXX"
34array = getShuffled(array)
35array
36"WBDXXHG"
37count = getUnifRand(0, len(array))
38count
39+1
40array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
41array
42"B"
43
44count = getUnifRand(4, 10)
45array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
46array
47"GEEP"
48array = getShuffled(array)
49array
50"PGEE"
51count = getUnifRand(0, len(array))
52count
53+4
54array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
55array
56"GEEP"
57
58count = getUnifRand(4, 10)
59array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
60array
61"JDEXJAKVG"
62array = getShuffled(array)
63array
64"XAJEGVDKJ"
65count = getUnifRand(0, len(array))
66count
67+4
68array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
69array
70"GDEA"
71
72count = getUnifRand(4, 10)
73array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
74array
75"GSARTFDAI"
76array = getShuffled(array)
77array
78"AITDGAFRS"
79count = getUnifRand(0, len(array))
80count
81+0
82array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
83array
84""
85
86count = getUnifRand(4, 10)
87array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
88array
89"VSJNIF"
90array = getShuffled(array)
91array
92"SJVINF"
93count = getUnifRand(0, len(array))
94count
95+0
96array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
97array
98""
99
100count = getUnifRand(4, 10)
101array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
102array
103"CGXCSVIB"
104array = getShuffled(array)
105array
106"BSICVXCG"
107count = getUnifRand(0, len(array))
108count
109+2
110array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
111array
112"CV"
113
114count = getUnifRand(4, 10)
115array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
116array
117"ONUNBCKS"
118array = getShuffled(array)
119array
120"UBNCONKS"
121count = getUnifRand(0, len(array))
122count
123+7
124array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
125array
126"UKNOCSN"
127
128count = getUnifRand(4, 10)
129array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
130array
131"VYCOG"
132array = getShuffled(array)
133array
134"VGCYO"
135count = getUnifRand(0, len(array))
136count
137+1
138array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
139array
140"O"
141
142count = getUnifRand(4, 10)
143array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
144array
145"XL", "FQ", "XS", "HV", "YW", "UA", "JX", "FN", "KN", "FT"
146array = getShuffled(array)
147array
148"FQ", "FN", "JX", "KN", "XL", "YW", "HV", "XS", "UA", "FT"
149count = getUnifRand(0, size(array))
150count
151+3
152array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
153array
154"JX", "FQ", "FN"
155
156count = getUnifRand(4, 10)
157array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
158array
159"AX", "HC", "KN", "XL", "EQ", "OC", "TN", "IY", "DD"
160array = getShuffled(array)
161array
162"HC", "AX", "KN", "DD", "EQ", "XL", "OC", "IY", "TN"
163count = getUnifRand(0, size(array))
164count
165+0
166array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
167array
168
169
170count = getUnifRand(4, 10)
171array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
172array
173"RS", "XQ", "BL", "IS", "KO", "LK", "XN", "EI", "SW"
174array = getShuffled(array)
175array
176"IS", "SW", "XQ", "BL", "XN", "LK", "RS", "EI", "KO"
177count = getUnifRand(0, size(array))
178count
179+0
180array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
181array
182
183
184count = getUnifRand(4, 10)
185array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
186array
187"BX", "RO", "CU", "AG", "EA", "VU", "VZ", "SL", "QT", "IZ"
188array = getShuffled(array)
189array
190"BX", "IZ", "EA", "AG", "SL", "QT", "RO", "CU", "VZ", "VU"
191count = getUnifRand(0, size(array))
192count
193+10
194array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
195array
196"VZ", "IZ", "EA", "VU", "RO", "BX", "CU", "AG", "QT", "SL"
197
198count = getUnifRand(4, 10)
199array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
200array
201"VF", "ZK", "RI", "HI", "TX"
202array = getShuffled(array)
203array
204"HI", "ZK", "TX", "RI", "VF"
205count = getUnifRand(0, size(array))
206count
207+1
208array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
209array
210"RI"
211
212count = getUnifRand(4, 10)
213array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
214array
215"LL", "AI", "CZ", "RM", "OY"
216array = getShuffled(array)
217array
218"CZ", "LL", "AI", "RM", "OY"
219count = getUnifRand(0, size(array))
220count
221+5
222array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
223array
224"AI", "OY", "RM", "LL", "CZ"
225
226count = getUnifRand(4, 10)
227array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
228array
229"EZ", "BE", "KY", "AV", "VT", "CQ", "TI", "EI", "WZ"
230array = getShuffled(array)
231array
232"VT", "AV", "EZ", "BE", "KY", "TI", "WZ", "CQ", "EI"
233count = getUnifRand(0, size(array))
234count
235+3
236array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
237array
238"WZ", "EI", "EZ"
239
240count = getUnifRand(4, 10)
241array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
242array
243"YK", "YS", "MP", "WP", "DR", "HX", "NV", "MV"
244array = getShuffled(array)
245array
246"WP", "DR", "YK", "MP", "NV", "HX", "YS", "MV"
247count = getUnifRand(0, size(array))
248count
249+2
250array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
251array
252"HX", "MP"
253
254count = getUnifRand(4, 10)
255array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
256array
257"DS", "XE", "AB", "GR", "LM", "YH", "EB", "JG"
258array = getShuffled(array)
259array
260"XE", "GR", "JG", "EB", "YH", "AB", "DS", "LM"
261count = getUnifRand(0, size(array))
262count
263+0
264array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
265array
266
267
268count = getUnifRand(4, 10)
269array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
270array
271"HZ", "YD", "QU", "II", "FL", "LS", "QJ", "XI", "LW", "CW"
272array = getShuffled(array)
273array
274"LS", "XI", "HZ", "LW", "CW", "QU", "II", "QJ", "YD", "FL"
275count = getUnifRand(0, size(array))
276count
277+0
278array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
279array
280
281
282count = getUnifRand(4, 10)
283array = getUnifRand(0, 9, count) ! generate random array for illustration.
284array
285+1, +7, +1, +7
286array = getShuffled(array)
287array
288+7, +1, +7, +1
289count = getUnifRand(0, size(array))
290count
291+2
292array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
293array
294+1, +7
295
296count = getUnifRand(4, 10)
297array = getUnifRand(0, 9, count) ! generate random array for illustration.
298array
299+9, +9, +6, +2, +4, +8, +0, +9
300array = getShuffled(array)
301array
302+4, +0, +9, +8, +9, +9, +2, +6
303count = getUnifRand(0, size(array))
304count
305+6
306array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
307array
308+4, +2, +6, +9, +9, +9
309
310count = getUnifRand(4, 10)
311array = getUnifRand(0, 9, count) ! generate random array for illustration.
312array
313+9, +4, +2, +8, +1, +6
314array = getShuffled(array)
315array
316+8, +2, +4, +1, +6, +9
317count = getUnifRand(0, size(array))
318count
319+5
320array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
321array
322+4, +8, +2, +9, +6
323
324count = getUnifRand(4, 10)
325array = getUnifRand(0, 9, count) ! generate random array for illustration.
326array
327+7, +7, +1, +1, +7, +3, +1, +6, +3, +7
328array = getShuffled(array)
329array
330+1, +1, +3, +6, +1, +7, +7, +3, +7, +7
331count = getUnifRand(0, size(array))
332count
333+8
334array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
335array
336+3, +1, +7, +7, +7, +3, +6, +1
337
338count = getUnifRand(4, 10)
339array = getUnifRand(0, 9, count) ! generate random array for illustration.
340array
341+5, +2, +0, +1, +8, +9, +7, +2
342array = getShuffled(array)
343array
344+7, +1, +8, +0, +5, +9, +2, +2
345count = getUnifRand(0, size(array))
346count
347+7
348array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
349array
350+2, +0, +5, +9, +2, +1, +7
351
352count = getUnifRand(4, 10)
353array = getUnifRand(0, 9, count) ! generate random array for illustration.
354array
355+8, +7, +6, +9, +2, +1, +1, +0, +4, +7
356array = getShuffled(array)
357array
358+1, +0, +4, +2, +1, +6, +7, +8, +9, +7
359count = getUnifRand(0, size(array))
360count
361+7
362array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
363array
364+9, +0, +1, +6, +1, +8, +7
365
366count = getUnifRand(4, 10)
367array = getUnifRand(0, 9, count) ! generate random array for illustration.
368array
369+8, +6, +2, +6, +3, +7, +6
370array = getShuffled(array)
371array
372+2, +7, +8, +6, +6, +6, +3
373count = getUnifRand(0, size(array))
374count
375+3
376array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
377array
378+3, +8, +6
379
380count = getUnifRand(4, 10)
381array = getUnifRand(0, 9, count) ! generate random array for illustration.
382array
383+0, +7, +7, +2, +5, +2
384array = getShuffled(array)
385array
386+2, +0, +5, +7, +2, +7
387count = getUnifRand(0, size(array))
388count
389+6
390array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
391array
392+5, +2, +2, +0, +7, +7
393
394count = getUnifRand(4, 10)
395array = getUnifRand(0, 9, count) ! generate random array for illustration.
396array
397+5, +6, +8, +7, +4, +8
398array = getShuffled(array)
399array
400+8, +7, +5, +6, +8, +4
401count = getUnifRand(0, size(array))
402count
403+6
404array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
405array
406+8, +5, +4, +6, +7, +8
407
408count = getUnifRand(4, 10)
409array = getUnifRand(0, 9, count) ! generate random array for illustration.
410array
411+1, +7, +7, +8, +5
412array = getShuffled(array)
413array
414+1, +7, +7, +5, +8
415count = getUnifRand(0, size(array))
416count
417+1
418array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
419array
420+1
421
422count = getUnifRand(4, 10)
423array = getUnifRand(.false., .true., count) ! generate random array for illustration.
424array
425F, F, T, T, T, T
426array = getShuffled(array)
427array
428F, T, T, T, T, F
429count = getUnifRand(0, size(array))
430count
431+3
432array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
433array
434F, T, T
435
436count = getUnifRand(4, 10)
437array = getUnifRand(.false., .true., count) ! generate random array for illustration.
438array
439T, F, T, F, T, F, F, F, F, F
440array = getShuffled(array)
441array
442T, F, T, F, F, F, T, F, F, F
443count = getUnifRand(0, size(array))
444count
445+9
446array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
447array
448F, F, T, F, T, F, F, F, F
449
450count = getUnifRand(4, 10)
451array = getUnifRand(.false., .true., count) ! generate random array for illustration.
452array
453T, T, F, T, T
454array = getShuffled(array)
455array
456T, F, T, T, T
457count = getUnifRand(0, size(array))
458count
459+3
460array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
461array
462T, F, T
463
464count = getUnifRand(4, 10)
465array = getUnifRand(.false., .true., count) ! generate random array for illustration.
466array
467F, F, F, T
468array = getShuffled(array)
469array
470F, F, F, T
471count = getUnifRand(0, size(array))
472count
473+3
474array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
475array
476F, F, F
477
478count = getUnifRand(4, 10)
479array = getUnifRand(.false., .true., count) ! generate random array for illustration.
480array
481F, T, F, F
482array = getShuffled(array)
483array
484F, T, F, F
485count = getUnifRand(0, size(array))
486count
487+0
488array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
489array
490
491
492count = getUnifRand(4, 10)
493array = getUnifRand(.false., .true., count) ! generate random array for illustration.
494array
495F, F, T, F, T, F, F, F
496array = getShuffled(array)
497array
498T, F, T, F, F, F, F, F
499count = getUnifRand(0, size(array))
500count
501+6
502array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
503array
504F, T, F, F, F, T
505
506count = getUnifRand(4, 10)
507array = getUnifRand(.false., .true., count) ! generate random array for illustration.
508array
509F, F, F, F, T
510array = getShuffled(array)
511array
512F, F, T, F, F
513count = getUnifRand(0, size(array))
514count
515+3
516array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
517array
518F, F, F
519
520count = getUnifRand(4, 10)
521array = getUnifRand(.false., .true., count) ! generate random array for illustration.
522array
523T, T, F, F, T, F, F
524array = getShuffled(array)
525array
526F, T, F, F, T, T, F
527count = getUnifRand(0, size(array))
528count
529+7
530array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
531array
532F, T, T, F, T, F, F
533
534count = getUnifRand(4, 10)
535array = getUnifRand(.false., .true., count) ! generate random array for illustration.
536array
537T, T, T, T, F
538array = getShuffled(array)
539array
540T, F, T, T, T
541count = getUnifRand(0, size(array))
542count
543+3
544array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
545array
546T, T, T
547
548count = getUnifRand(4, 10)
549array = getUnifRand(.false., .true., count) ! generate random array for illustration.
550array
551F, T, T, T, F, T, T, T
552array = getShuffled(array)
553array
554T, T, T, F, F, T, T, T
555count = getUnifRand(0, size(array))
556count
557+1
558array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
559array
560T
561
562count = getUnifRand(4, 10)
563array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
564array
565(+0.751330853E-1, +0.183801413), (+0.814792275, +0.101836145), (+0.997358501, +0.842639625), (+0.874128461, +0.281576753)
566array = getShuffled(array)
567array
568(+0.751330853E-1, +0.183801413), (+0.874128461, +0.281576753), (+0.814792275, +0.101836145), (+0.997358501, +0.842639625)
569count = getUnifRand(0, size(array))
570count
571+1
572array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
573array
574(+0.751330853E-1, +0.183801413)
575
576count = getUnifRand(4, 10)
577array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
578array
579(+0.816357255, +0.612030029E-1), (+0.247640789, +0.697766781), (+0.364763677, +0.149942517), (+0.351127565, +0.488044739), (+0.187158883, +0.257729173), (+0.797261298, +0.675964355), (+0.416827679, +0.307733655), (+0.275555253, +0.717491210)
580array = getShuffled(array)
581array
582(+0.797261298, +0.675964355), (+0.364763677, +0.149942517), (+0.351127565, +0.488044739), (+0.416827679, +0.307733655), (+0.816357255, +0.612030029E-1), (+0.247640789, +0.697766781), (+0.187158883, +0.257729173), (+0.275555253, +0.717491210)
583count = getUnifRand(0, size(array))
584count
585+3
586array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
587array
588(+0.816357255, +0.612030029E-1), (+0.797261298, +0.675964355), (+0.351127565, +0.488044739)
589
590count = getUnifRand(4, 10)
591array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
592array
593(+0.269145846, +0.325437188E-1), (+0.283939004, +0.954343975), (+0.266575754, +0.684626520), (+0.228516102, +0.761906743), (+0.121420443, +0.332813740)
594array = getShuffled(array)
595array
596(+0.228516102, +0.761906743), (+0.283939004, +0.954343975), (+0.266575754, +0.684626520), (+0.121420443, +0.332813740), (+0.269145846, +0.325437188E-1)
597count = getUnifRand(0, size(array))
598count
599+1
600array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
601array
602(+0.121420443, +0.332813740)
603
604count = getUnifRand(4, 10)
605array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
606array
607(+0.866146147, +0.223036528), (+0.843287587, +0.622010946), (+0.330327272, +0.673686862), (+0.425304711, +0.714977562)
608array = getShuffled(array)
609array
610(+0.866146147, +0.223036528), (+0.843287587, +0.622010946), (+0.425304711, +0.714977562), (+0.330327272, +0.673686862)
611count = getUnifRand(0, size(array))
612count
613+0
614array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
615array
616
617
618count = getUnifRand(4, 10)
619array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
620array
621(+0.434157550, +0.265131533), (+0.562423468E-2, +0.621740341), (+0.904558301E-1, +0.792295039), (+0.863128722, +0.217217267)
622array = getShuffled(array)
623array
624(+0.434157550, +0.265131533), (+0.562423468E-2, +0.621740341), (+0.863128722, +0.217217267), (+0.904558301E-1, +0.792295039)
625count = getUnifRand(0, size(array))
626count
627+2
628array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
629array
630(+0.863128722, +0.217217267), (+0.904558301E-1, +0.792295039)
631
632count = getUnifRand(4, 10)
633array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
634array
635(+0.645850122, +0.957004488), (+0.855530381, +0.973664582), (+0.123704255, +0.874597788), (+0.660141647, +0.302008092), (+0.356422544, +0.362690091E-1), (+0.273054183, +0.451752663)
636array = getShuffled(array)
637array
638(+0.855530381, +0.973664582), (+0.660141647, +0.302008092), (+0.356422544, +0.362690091E-1), (+0.123704255, +0.874597788), (+0.645850122, +0.957004488), (+0.273054183, +0.451752663)
639count = getUnifRand(0, size(array))
640count
641+0
642array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
643array
644
645
646count = getUnifRand(4, 10)
647array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
648array
649(+0.207663178, +0.363863647), (+0.481606662, +0.902226090), (+0.756604791, +0.487679660), (+0.789286852, +0.485151649), (+0.189216137, +0.786870182)
650array = getShuffled(array)
651array
652(+0.481606662, +0.902226090), (+0.756604791, +0.487679660), (+0.207663178, +0.363863647), (+0.789286852, +0.485151649), (+0.189216137, +0.786870182)
653count = getUnifRand(0, size(array))
654count
655+2
656array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
657array
658(+0.207663178, +0.363863647), (+0.189216137, +0.786870182)
659
660count = getUnifRand(4, 10)
661array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
662array
663(+0.702646613, +0.469562411E-1), (+0.201419771, +0.914257765), (+0.407967210, +0.894890785), (+0.552247345, +0.970573545), (+0.384296775, +0.621400058), (+0.957170963, +0.734451473), (+0.671901941, +0.369824290)
664array = getShuffled(array)
665array
666(+0.957170963, +0.734451473), (+0.671901941, +0.369824290), (+0.384296775, +0.621400058), (+0.201419771, +0.914257765), (+0.407967210, +0.894890785), (+0.552247345, +0.970573545), (+0.702646613, +0.469562411E-1)
667count = getUnifRand(0, size(array))
668count
669+0
670array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
671array
672
673
674count = getUnifRand(4, 10)
675array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
676array
677(+0.206587315, +0.876139343), (+0.799226761E-1, +0.808930933), (+0.151602685, +0.675778031), (+0.278506279E-1, +0.462710619), (+0.207300127, +0.872811377), (+0.612495124, +0.902936280)
678array = getShuffled(array)
679array
680(+0.278506279E-1, +0.462710619), (+0.612495124, +0.902936280), (+0.206587315, +0.876139343), (+0.799226761E-1, +0.808930933), (+0.151602685, +0.675778031), (+0.207300127, +0.872811377)
681count = getUnifRand(0, size(array))
682count
683+0
684array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
685array
686
687
688count = getUnifRand(4, 10)
689array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
690array
691(+0.617786646, +0.786175013), (+0.646402597, +0.789577127), (+0.799457967, +0.461989343), (+0.380164504, +0.442392290)
692array = getShuffled(array)
693array
694(+0.799457967, +0.461989343), (+0.646402597, +0.789577127), (+0.617786646, +0.786175013), (+0.380164504, +0.442392290)
695count = getUnifRand(0, size(array))
696count
697+4
698array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
699array
700(+0.380164504, +0.442392290), (+0.617786646, +0.786175013), (+0.799457967, +0.461989343), (+0.646402597, +0.789577127)
701
702count = getUnifRand(4, 10)
703array = getUnifRand(0., 1., count) ! generate random array for illustration.
704array
705+0.487201154, +0.958853304, +0.478132129, +0.684742272, +0.422990978, +0.293059766, +0.232451081, +0.103479266, +0.968977749
706array = getShuffled(array)
707array
708+0.487201154, +0.103479266, +0.684742272, +0.422990978, +0.968977749, +0.478132129, +0.232451081, +0.293059766, +0.958853304
709count = getUnifRand(0, size(array))
710count
711+9
712array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
713array
714+0.684742272, +0.422990978, +0.958853304, +0.968977749, +0.103479266, +0.293059766, +0.232451081, +0.487201154, +0.478132129
715
716count = getUnifRand(4, 10)
717array = getUnifRand(0., 1., count) ! generate random array for illustration.
718array
719+0.604377627, +0.405595124, +0.268067300, +0.825915694, +0.396593750, +0.184678614, +0.871406078, +0.663278639, +0.270405948, +0.142071247
720array = getShuffled(array)
721array
722+0.396593750, +0.871406078, +0.604377627, +0.825915694, +0.268067300, +0.663278639, +0.270405948, +0.405595124, +0.184678614, +0.142071247
723count = getUnifRand(0, size(array))
724count
725+5
726array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
727array
728+0.825915694, +0.396593750, +0.604377627, +0.663278639, +0.184678614
729
730count = getUnifRand(4, 10)
731array = getUnifRand(0., 1., count) ! generate random array for illustration.
732array
733+0.726850569, +0.603545308E-1, +0.997810304, +0.833616853, +0.203806102, +0.857486367, +0.367431402, +0.782361090, +0.229169786, +0.547376931
734array = getShuffled(array)
735array
736+0.203806102, +0.997810304, +0.547376931, +0.367431402, +0.782361090, +0.603545308E-1, +0.833616853, +0.229169786, +0.726850569, +0.857486367
737count = getUnifRand(0, size(array))
738count
739+9
740array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
741array
742+0.726850569, +0.367431402, +0.997810304, +0.203806102, +0.857486367, +0.603545308E-1, +0.782361090, +0.833616853, +0.547376931
743
744count = getUnifRand(4, 10)
745array = getUnifRand(0., 1., count) ! generate random array for illustration.
746array
747+0.806127965, +0.190615952, +0.293869972E-1, +0.974807203, +0.921331525, +0.448071957E-1, +0.169981122, +0.785794318
748array = getShuffled(array)
749array
750+0.806127965, +0.293869972E-1, +0.448071957E-1, +0.169981122, +0.785794318, +0.190615952, +0.974807203, +0.921331525
751count = getUnifRand(0, size(array))
752count
753+0
754array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
755array
756
757
758count = getUnifRand(4, 10)
759array = getUnifRand(0., 1., count) ! generate random array for illustration.
760array
761+0.528634131, +0.129840136, +0.146222830, +0.198880672, +0.474606276, +0.847750604, +0.547472179
762array = getShuffled(array)
763array
764+0.146222830, +0.547472179, +0.198880672, +0.129840136, +0.474606276, +0.847750604, +0.528634131
765count = getUnifRand(0, size(array))
766count
767+1
768array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
769array
770+0.146222830
771
772count = getUnifRand(4, 10)
773array = getUnifRand(0., 1., count) ! generate random array for illustration.
774array
775+0.618891418, +0.868036926, +0.966477454, +0.355221927, +0.672994733, +0.877854049
776array = getShuffled(array)
777array
778+0.672994733, +0.966477454, +0.868036926, +0.877854049, +0.355221927, +0.618891418
779count = getUnifRand(0, size(array))
780count
781+6
782array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
783array
784+0.966477454, +0.672994733, +0.868036926, +0.877854049, +0.618891418, +0.355221927
785
786count = getUnifRand(4, 10)
787array = getUnifRand(0., 1., count) ! generate random array for illustration.
788array
789+0.437191010, +0.585337162, +0.512874544, +0.393751502, +0.400104463, +0.682900667, +0.732358992, +0.228251040, +0.297055423
790array = getShuffled(array)
791array
792+0.512874544, +0.682900667, +0.585337162, +0.437191010, +0.732358992, +0.297055423, +0.393751502, +0.400104463, +0.228251040
793count = getUnifRand(0, size(array))
794count
795+8
796array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
797array
798+0.732358992, +0.228251040, +0.682900667, +0.512874544, +0.400104463, +0.585337162, +0.297055423, +0.437191010
799
800count = getUnifRand(4, 10)
801array = getUnifRand(0., 1., count) ! generate random array for illustration.
802array
803+0.178422153, +0.280111253, +0.801081002, +0.415141642, +0.650645792, +0.350336075, +0.879248381, +0.263728499, +0.183480978E-2, +0.160227954
804array = getShuffled(array)
805array
806+0.650645792, +0.415141642, +0.280111253, +0.160227954, +0.183480978E-2, +0.350336075, +0.879248381, +0.178422153, +0.263728499, +0.801081002
807count = getUnifRand(0, size(array))
808count
809+5
810array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
811array
812+0.350336075, +0.879248381, +0.280111253, +0.650645792, +0.178422153
813
814count = getUnifRand(4, 10)
815array = getUnifRand(0., 1., count) ! generate random array for illustration.
816array
817+0.908190012E-2, +0.677345991, +0.897163391, +0.975470662, +0.344388068, +0.954382062, +0.807369888
818array = getShuffled(array)
819array
820+0.344388068, +0.908190012E-2, +0.954382062, +0.975470662, +0.677345991, +0.897163391, +0.807369888
821count = getUnifRand(0, size(array))
822count
823+5
824array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
825array
826+0.344388068, +0.954382062, +0.908190012E-2, +0.975470662, +0.807369888
827
828count = getUnifRand(4, 10)
829array = getUnifRand(0., 1., count) ! generate random array for illustration.
830array
831+0.815311670, +0.500263333, +0.894390404, +0.957159162, +0.908702433
832array = getShuffled(array)
833array
834+0.815311670, +0.894390404, +0.500263333, +0.957159162, +0.908702433
835count = getUnifRand(0, size(array))
836count
837+1
838array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
839array
840+0.500263333
841
Test:
test_pm_arrayShuffle
Todo:
Low Priority: This generic interface can be extended to 2D input objects.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 145 of file pm_arrayShuffle.F90.


The documentation for this interface was generated from the following file: