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"QSAMLDVYYU"
6array = getShuffled(array)
7array
8"UYQMVSYDAL"
9count = getUnifRand(0, len(array))
10count
11+6
12array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
13array
14"AMQVYY"
15
16count = getUnifRand(4, 10)
17array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
18array
19"MDFVOS"
20array = getShuffled(array)
21array
22"OFMSDV"
23count = getUnifRand(0, len(array))
24count
25+2
26array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
27array
28"FO"
29
30count = getUnifRand(4, 10)
31array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
32array
33"CZISCF"
34array = getShuffled(array)
35array
36"CSFCZI"
37count = getUnifRand(0, len(array))
38count
39+1
40array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
41array
42"S"
43
44count = getUnifRand(4, 10)
45array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
46array
47"RYALZUDA"
48array = getShuffled(array)
49array
50"DUYALRAZ"
51count = getUnifRand(0, len(array))
52count
53+3
54array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
55array
56"AYL"
57
58count = getUnifRand(4, 10)
59array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
60array
61"RVFTET"
62array = getShuffled(array)
63array
64"TERFVT"
65count = getUnifRand(0, len(array))
66count
67+4
68array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
69array
70"TFVT"
71
72count = getUnifRand(4, 10)
73array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
74array
75"OGPQIULBT"
76array = getShuffled(array)
77array
78"UGBIPOQLT"
79count = getUnifRand(0, len(array))
80count
81+9
82array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
83array
84"OTLQGUIBP"
85
86count = getUnifRand(4, 10)
87array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
88array
89"NWFMGQWD"
90array = getShuffled(array)
91array
92"FQGWWMND"
93count = getUnifRand(0, len(array))
94count
95+6
96array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
97array
98"QNWFGM"
99
100count = getUnifRand(4, 10)
101array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
102array
103"YEPZFMK"
104array = getShuffled(array)
105array
106"KYZMFEP"
107count = getUnifRand(0, len(array))
108count
109+2
110array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
111array
112"YE"
113
114count = getUnifRand(4, 10)
115array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
116array
117"ZTYXZ"
118array = getShuffled(array)
119array
120"XTZZY"
121count = getUnifRand(0, len(array))
122count
123+3
124array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
125array
126"TXZ"
127
128count = getUnifRand(4, 10)
129array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
130array
131"URWSHZKLO"
132array = getShuffled(array)
133array
134"UZWKLSOHR"
135count = getUnifRand(0, len(array))
136count
137+2
138array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
139array
140"ZS"
141
142count = getUnifRand(4, 10)
143array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
144array
145"YE", "GZ", "YM", "LE", "NR", "NA", "FN", "HO", "JY"
146array = getShuffled(array)
147array
148"GZ", "YM", "JY", "NA", "FN", "YE", "HO", "NR", "LE"
149count = getUnifRand(0, size(array))
150count
151+2
152array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
153array
154"YE", "JY"
155
156count = getUnifRand(4, 10)
157array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
158array
159"HI", "LB", "NF", "NQ", "KG", "KK"
160array = getShuffled(array)
161array
162"KK", "HI", "NQ", "NF", "KG", "LB"
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"PU", "NR", "VY", "PR", "TE", "SH", "DY"
174array = getShuffled(array)
175array
176"NR", "DY", "TE", "VY", "PR", "PU", "SH"
177count = getUnifRand(0, size(array))
178count
179+6
180array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
181array
182"DY", "PU", "SH", "VY", "PR", "NR"
183
184count = getUnifRand(4, 10)
185array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
186array
187"LJ", "RP", "CJ", "ME", "KW", "TK", "RY"
188array = getShuffled(array)
189array
190"KW", "RY", "LJ", "RP", "ME", "CJ", "TK"
191count = getUnifRand(0, size(array))
192count
193+0
194array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
195array
196
197
198count = getUnifRand(4, 10)
199array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
200array
201"TV", "HP", "CL", "MZ"
202array = getShuffled(array)
203array
204"HP", "CL", "TV", "MZ"
205count = getUnifRand(0, size(array))
206count
207+0
208array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
209array
210
211
212count = getUnifRand(4, 10)
213array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
214array
215"AO", "ZZ", "RY", "YU", "WW", "JF"
216array = getShuffled(array)
217array
218"YU", "JF", "WW", "ZZ", "RY", "AO"
219count = getUnifRand(0, size(array))
220count
221+5
222array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
223array
224"AO", "WW", "JF", "ZZ", "YU"
225
226count = getUnifRand(4, 10)
227array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
228array
229"AD", "BB", "DF", "HO", "WL"
230array = getShuffled(array)
231array
232"BB", "AD", "DF", "WL", "HO"
233count = getUnifRand(0, size(array))
234count
235+3
236array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
237array
238"DF", "WL", "BB"
239
240count = getUnifRand(4, 10)
241array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
242array
243"EB", "OK", "PV", "SJ", "DS", "YT", "CV", "QV", "IC"
244array = getShuffled(array)
245array
246"PV", "YT", "EB", "DS", "QV", "IC", "SJ", "CV", "OK"
247count = getUnifRand(0, size(array))
248count
249+6
250array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
251array
252"QV", "EB", "CV", "YT", "SJ", "DS"
253
254count = getUnifRand(4, 10)
255array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
256array
257"SK", "GN", "AX", "AV", "IC", "VO", "IX"
258array = getShuffled(array)
259array
260"SK", "AX", "AV", "IX", "VO", "IC", "GN"
261count = getUnifRand(0, size(array))
262count
263+2
264array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
265array
266"VO", "GN"
267
268count = getUnifRand(4, 10)
269array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
270array
271"ND", "LM", "BA", "ZA"
272array = getShuffled(array)
273array
274"BA", "ND", "LM", "ZA"
275count = getUnifRand(0, size(array))
276count
277+2
278array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
279array
280"LM", "ND"
281
282count = getUnifRand(4, 10)
283array = getUnifRand(0, 9, count) ! generate random array for illustration.
284array
285+6, +5, +0, +5, +6, +3, +8, +7
286array = getShuffled(array)
287array
288+3, +8, +7, +6, +5, +6, +5, +0
289count = getUnifRand(0, size(array))
290count
291+0
292array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
293array
294
295
296count = getUnifRand(4, 10)
297array = getUnifRand(0, 9, count) ! generate random array for illustration.
298array
299+9, +0, +6, +5, +3
300array = getShuffled(array)
301array
302+9, +3, +5, +6, +0
303count = getUnifRand(0, size(array))
304count
305+3
306array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
307array
308+9, +5, +0
309
310count = getUnifRand(4, 10)
311array = getUnifRand(0, 9, count) ! generate random array for illustration.
312array
313+5, +0, +2, +6
314array = getShuffled(array)
315array
316+6, +0, +2, +5
317count = getUnifRand(0, size(array))
318count
319+0
320array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
321array
322
323
324count = getUnifRand(4, 10)
325array = getUnifRand(0, 9, count) ! generate random array for illustration.
326array
327+1, +1, +2, +0, +8, +8, +4, +8, +6
328array = getShuffled(array)
329array
330+2, +1, +0, +8, +6, +8, +4, +8, +1
331count = getUnifRand(0, size(array))
332count
333+6
334array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
335array
336+2, +1, +8, +8, +8, +4
337
338count = getUnifRand(4, 10)
339array = getUnifRand(0, 9, count) ! generate random array for illustration.
340array
341+0, +7, +8, +7, +7, +2, +1, +2, +0
342array = getShuffled(array)
343array
344+2, +7, +0, +7, +7, +1, +0, +8, +2
345count = getUnifRand(0, size(array))
346count
347+7
348array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
349array
350+7, +0, +7, +1, +2, +2, +7
351
352count = getUnifRand(4, 10)
353array = getUnifRand(0, 9, count) ! generate random array for illustration.
354array
355+7, +6, +8, +7, +3, +5, +0, +2
356array = getShuffled(array)
357array
358+3, +7, +6, +2, +0, +8, +7, +5
359count = getUnifRand(0, size(array))
360count
361+0
362array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
363array
364
365
366count = getUnifRand(4, 10)
367array = getUnifRand(0, 9, count) ! generate random array for illustration.
368array
369+9, +3, +3, +1, +3, +2, +7
370array = getShuffled(array)
371array
372+3, +1, +3, +3, +2, +9, +7
373count = getUnifRand(0, size(array))
374count
375+4
376array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
377array
378+9, +3, +3, +7
379
380count = getUnifRand(4, 10)
381array = getUnifRand(0, 9, count) ! generate random array for illustration.
382array
383+7, +1, +2, +0, +1, +5
384array = getShuffled(array)
385array
386+5, +0, +7, +2, +1, +1
387count = getUnifRand(0, size(array))
388count
389+2
390array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
391array
392+1, +0
393
394count = getUnifRand(4, 10)
395array = getUnifRand(0, 9, count) ! generate random array for illustration.
396array
397+2, +9, +3, +3, +8
398array = getShuffled(array)
399array
400+3, +3, +2, +9, +8
401count = getUnifRand(0, size(array))
402count
403+3
404array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
405array
406+3, +8, +2
407
408count = getUnifRand(4, 10)
409array = getUnifRand(0, 9, count) ! generate random array for illustration.
410array
411+6, +4, +7, +9, +1, +2
412array = getShuffled(array)
413array
414+7, +1, +2, +4, +6, +9
415count = getUnifRand(0, size(array))
416count
417+0
418array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
419array
420
421
422count = getUnifRand(4, 10)
423array = getUnifRand(.false., .true., count) ! generate random array for illustration.
424array
425T, F, T, T, F
426array = getShuffled(array)
427array
428F, T, F, T, T
429count = getUnifRand(0, size(array))
430count
431+0
432array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
433array
434
435
436count = getUnifRand(4, 10)
437array = getUnifRand(.false., .true., count) ! generate random array for illustration.
438array
439T, T, T, F, F, T, F, T, F
440array = getShuffled(array)
441array
442F, T, T, F, F, T, F, T, T
443count = getUnifRand(0, size(array))
444count
445+7
446array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
447array
448T, F, T, F, T, T, T
449
450count = getUnifRand(4, 10)
451array = getUnifRand(.false., .true., count) ! generate random array for illustration.
452array
453T, F, T, F, T, T, F, F, F
454array = getShuffled(array)
455array
456F, T, T, F, T, F, F, F, T
457count = getUnifRand(0, size(array))
458count
459+4
460array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
461array
462T, T, T, F
463
464count = getUnifRand(4, 10)
465array = getUnifRand(.false., .true., count) ! generate random array for illustration.
466array
467F, T, F, F, F, F, F, T
468array = getShuffled(array)
469array
470F, T, F, F, F, F, F, T
471count = getUnifRand(0, size(array))
472count
473+5
474array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
475array
476F, F, F, F, T
477
478count = getUnifRand(4, 10)
479array = getUnifRand(.false., .true., count) ! generate random array for illustration.
480array
481F, F, T, T, F
482array = getShuffled(array)
483array
484T, F, F, T, F
485count = getUnifRand(0, size(array))
486count
487+4
488array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
489array
490F, T, F, F
491
492count = getUnifRand(4, 10)
493array = getUnifRand(.false., .true., count) ! generate random array for illustration.
494array
495F, F, T, T, F, T, T
496array = getShuffled(array)
497array
498T, T, T, F, F, F, T
499count = getUnifRand(0, size(array))
500count
501+2
502array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
503array
504T, T
505
506count = getUnifRand(4, 10)
507array = getUnifRand(.false., .true., count) ! generate random array for illustration.
508array
509F, F, F, T, T, F, T, F
510array = getShuffled(array)
511array
512F, F, F, T, F, T, T, F
513count = getUnifRand(0, size(array))
514count
515+8
516array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
517array
518F, F, F, F, T, T, T, F
519
520count = getUnifRand(4, 10)
521array = getUnifRand(.false., .true., count) ! generate random array for illustration.
522array
523T, T, T, T, T, F, F, T
524array = getShuffled(array)
525array
526F, T, T, T, T, T, F, T
527count = getUnifRand(0, size(array))
528count
529+3
530array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
531array
532T, T, T
533
534count = getUnifRand(4, 10)
535array = getUnifRand(.false., .true., count) ! generate random array for illustration.
536array
537F, T, T, T, T
538array = getShuffled(array)
539array
540T, T, T, F, T
541count = getUnifRand(0, size(array))
542count
543+5
544array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
545array
546T, F, T, T, T
547
548count = getUnifRand(4, 10)
549array = getUnifRand(.false., .true., count) ! generate random array for illustration.
550array
551F, T, F, T, F, T, T, F
552array = getShuffled(array)
553array
554T, F, T, F, T, F, T, F
555count = getUnifRand(0, size(array))
556count
557+2
558array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
559array
560F, T
561
562count = getUnifRand(4, 10)
563array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
564array
565(+0.236457169, +0.372481942E-1), (+0.620558321, +0.225238979), (+0.613987088, +0.198738396), (+0.450425982, +0.975796163), (+0.588115931, +0.703201532)
566array = getShuffled(array)
567array
568(+0.613987088, +0.198738396), (+0.450425982, +0.975796163), (+0.236457169, +0.372481942E-1), (+0.620558321, +0.225238979), (+0.588115931, +0.703201532)
569count = getUnifRand(0, size(array))
570count
571+3
572array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
573array
574(+0.450425982, +0.975796163), (+0.588115931, +0.703201532), (+0.613987088, +0.198738396)
575
576count = getUnifRand(4, 10)
577array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
578array
579(+0.192514718, +0.113111556), (+0.437338352, +0.722880661), (+0.547305286, +0.122749269), (+0.969577551, +0.986249208), (+0.712779939, +0.147970319), (+0.750182509, +0.254819512), (+0.321369529, +0.914896727), (+0.837500691E-1, +0.520659506)
580array = getShuffled(array)
581array
582(+0.750182509, +0.254819512), (+0.547305286, +0.122749269), (+0.321369529, +0.914896727), (+0.437338352, +0.722880661), (+0.837500691E-1, +0.520659506), (+0.712779939, +0.147970319), (+0.969577551, +0.986249208), (+0.192514718, +0.113111556)
583count = getUnifRand(0, size(array))
584count
585+4
586array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
587array
588(+0.437338352, +0.722880661), (+0.192514718, +0.113111556), (+0.712779939, +0.147970319), (+0.321369529, +0.914896727)
589
590count = getUnifRand(4, 10)
591array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
592array
593(+0.446414232, +0.161339223), (+0.773889959, +0.736664712), (+0.458979607, +0.163619936), (+0.649872243, +0.726339519), (+0.822546601, +0.733868659), (+0.875087023, +0.970146537), (+0.842108309, +0.837211013), (+0.252065718, +0.943914294)
594array = getShuffled(array)
595array
596(+0.842108309, +0.837211013), (+0.773889959, +0.736664712), (+0.822546601, +0.733868659), (+0.875087023, +0.970146537), (+0.252065718, +0.943914294), (+0.446414232, +0.161339223), (+0.649872243, +0.726339519), (+0.458979607, +0.163619936)
597count = getUnifRand(0, size(array))
598count
599+4
600array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
601array
602(+0.446414232, +0.161339223), (+0.458979607, +0.163619936), (+0.773889959, +0.736664712), (+0.649872243, +0.726339519)
603
604count = getUnifRand(4, 10)
605array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
606array
607(+0.886526108E-1, +0.417054236), (+0.873563528, +0.526678562E-2), (+0.227147043, +0.982010782), (+0.668107748, +0.789273798), (+0.534331262, +0.736161888), (+0.442174315, +0.648055017), (+0.402749002, +0.521283090), (+0.428591073, +0.751927495)
608array = getShuffled(array)
609array
610(+0.886526108E-1, +0.417054236), (+0.227147043, +0.982010782), (+0.668107748, +0.789273798), (+0.534331262, +0.736161888), (+0.402749002, +0.521283090), (+0.873563528, +0.526678562E-2), (+0.442174315, +0.648055017), (+0.428591073, +0.751927495)
611count = getUnifRand(0, size(array))
612count
613+7
614array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
615array
616(+0.873563528, +0.526678562E-2), (+0.442174315, +0.648055017), (+0.534331262, +0.736161888), (+0.402749002, +0.521283090), (+0.886526108E-1, +0.417054236), (+0.428591073, +0.751927495), (+0.668107748, +0.789273798)
617
618count = getUnifRand(4, 10)
619array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
620array
621(+0.467798114E-1, +0.495126069), (+0.855228126, +0.681790411), (+0.618081629, +0.105156839), (+0.905384421E-1, +0.194232464), (+0.252223015E-1, +0.618544102), (+0.887766719, +0.926808834), (+0.144039154, +0.613445282), (+0.381111920, +0.953515172)
622array = getShuffled(array)
623array
624(+0.618081629, +0.105156839), (+0.252223015E-1, +0.618544102), (+0.905384421E-1, +0.194232464), (+0.381111920, +0.953515172), (+0.144039154, +0.613445282), (+0.855228126, +0.681790411), (+0.887766719, +0.926808834), (+0.467798114E-1, +0.495126069)
625count = getUnifRand(0, size(array))
626count
627+5
628array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
629array
630(+0.618081629, +0.105156839), (+0.905384421E-1, +0.194232464), (+0.887766719, +0.926808834), (+0.467798114E-1, +0.495126069), (+0.144039154, +0.613445282)
631
632count = getUnifRand(4, 10)
633array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
634array
635(+0.923682928, +0.587326944), (+0.303708136, +0.677110076), (+0.712238550E-1, +0.487036228), (+0.675812304, +0.872579634), (+0.719198704, +0.816288471)
636array = getShuffled(array)
637array
638(+0.719198704, +0.816288471), (+0.303708136, +0.677110076), (+0.712238550E-1, +0.487036228), (+0.675812304, +0.872579634), (+0.923682928, +0.587326944)
639count = getUnifRand(0, size(array))
640count
641+1
642array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
643array
644(+0.712238550E-1, +0.487036228)
645
646count = getUnifRand(4, 10)
647array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
648array
649(+0.473743439, +0.971214175), (+0.515890002, +0.486422122), (+0.736594200E-1, +0.172737062), (+0.836741865, +0.294061899E-1), (+0.199129045, +0.705178976), (+0.642369270, +0.686233044E-1), (+0.565157533, +0.707833767), (+0.688023686, +0.534220278), (+0.606411636, +0.543363988), (+0.428259373E-1, +0.214541256)
650array = getShuffled(array)
651array
652(+0.428259373E-1, +0.214541256), (+0.688023686, +0.534220278), (+0.642369270, +0.686233044E-1), (+0.736594200E-1, +0.172737062), (+0.606411636, +0.543363988), (+0.836741865, +0.294061899E-1), (+0.473743439, +0.971214175), (+0.565157533, +0.707833767), (+0.515890002, +0.486422122), (+0.199129045, +0.705178976)
653count = getUnifRand(0, size(array))
654count
655+7
656array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
657array
658(+0.515890002, +0.486422122), (+0.736594200E-1, +0.172737062), (+0.836741865, +0.294061899E-1), (+0.565157533, +0.707833767), (+0.642369270, +0.686233044E-1), (+0.606411636, +0.543363988), (+0.688023686, +0.534220278)
659
660count = getUnifRand(4, 10)
661array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
662array
663(+0.294996440, +0.270303965), (+0.759801030, +0.482282102), (+0.237049341, +0.539956331), (+0.506844223, +0.638170362), (+0.294561207, +0.570023656E-1), (+0.440932751, +0.773765802), (+0.163222790, +0.947291255E-1)
664array = getShuffled(array)
665array
666(+0.759801030, +0.482282102), (+0.506844223, +0.638170362), (+0.294996440, +0.270303965), (+0.294561207, +0.570023656E-1), (+0.237049341, +0.539956331), (+0.163222790, +0.947291255E-1), (+0.440932751, +0.773765802)
667count = getUnifRand(0, size(array))
668count
669+3
670array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
671array
672(+0.294561207, +0.570023656E-1), (+0.759801030, +0.482282102), (+0.163222790, +0.947291255E-1)
673
674count = getUnifRand(4, 10)
675array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
676array
677(+0.557914972E-1, +0.826946855), (+0.183230162, +0.851827085), (+0.536072254E-2, +0.653061867E-1), (+0.144756615, +0.921711981), (+0.861820281, +0.206179500), (+0.924912632, +0.768901348), (+0.401797593, +0.590510428), (+0.663143396E-1, +0.531136811), (+0.438815534, +0.442660034)
678array = getShuffled(array)
679array
680(+0.861820281, +0.206179500), (+0.557914972E-1, +0.826946855), (+0.924912632, +0.768901348), (+0.401797593, +0.590510428), (+0.144756615, +0.921711981), (+0.663143396E-1, +0.531136811), (+0.536072254E-2, +0.653061867E-1), (+0.438815534, +0.442660034), (+0.183230162, +0.851827085)
681count = getUnifRand(0, size(array))
682count
683+1
684array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
685array
686(+0.144756615, +0.921711981)
687
688count = getUnifRand(4, 10)
689array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
690array
691(+0.651332021, +0.758505583), (+0.888592005E-2, +0.393595159), (+0.420730114, +0.904795408), (+0.973716795, +0.193711460), (+0.993791223E-1, +0.169614196), (+0.632548213, +0.379353344), (+0.946054697, +0.707690001), (+0.690547824, +0.830768168), (+0.387958944, +0.831639171), (+0.348164678, +0.327145576)
692array = getShuffled(array)
693array
694(+0.973716795, +0.193711460), (+0.888592005E-2, +0.393595159), (+0.420730114, +0.904795408), (+0.348164678, +0.327145576), (+0.632548213, +0.379353344), (+0.993791223E-1, +0.169614196), (+0.651332021, +0.758505583), (+0.387958944, +0.831639171), (+0.690547824, +0.830768168), (+0.946054697, +0.707690001)
695count = getUnifRand(0, size(array))
696count
697+1
698array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
699array
700(+0.690547824, +0.830768168)
701
702count = getUnifRand(4, 10)
703array = getUnifRand(0., 1., count) ! generate random array for illustration.
704array
705+0.832107842, +0.450377226, +0.233305693, +0.919365764, +0.698654234, +0.178015947, +0.446732998, +0.583591759, +0.431384206, +0.756679416
706array = getShuffled(array)
707array
708+0.431384206, +0.233305693, +0.446732998, +0.178015947, +0.698654234, +0.756679416, +0.832107842, +0.583591759, +0.450377226, +0.919365764
709count = getUnifRand(0, size(array))
710count
711+3
712array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
713array
714+0.698654234, +0.832107842, +0.756679416
715
716count = getUnifRand(4, 10)
717array = getUnifRand(0., 1., count) ! generate random array for illustration.
718array
719+0.254659474, +0.988009214, +0.199089527, +0.236618996, +0.416619837, +0.424170792
720array = getShuffled(array)
721array
722+0.424170792, +0.199089527, +0.236618996, +0.254659474, +0.416619837, +0.988009214
723count = getUnifRand(0, size(array))
724count
725+3
726array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
727array
728+0.416619837, +0.236618996, +0.988009214
729
730count = getUnifRand(4, 10)
731array = getUnifRand(0., 1., count) ! generate random array for illustration.
732array
733+0.311739385, +0.838033676, +0.617473900, +0.760530472, +0.985780478, +0.944927096, +0.666189075
734array = getShuffled(array)
735array
736+0.838033676, +0.617473900, +0.944927096, +0.760530472, +0.985780478, +0.666189075, +0.311739385
737count = getUnifRand(0, size(array))
738count
739+5
740array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
741array
742+0.760530472, +0.666189075, +0.617473900, +0.985780478, +0.838033676
743
744count = getUnifRand(4, 10)
745array = getUnifRand(0., 1., count) ! generate random array for illustration.
746array
747+0.934136748, +0.532863557, +0.801217854, +0.347375393, +0.984584630, +0.548526406, +0.834214330
748array = getShuffled(array)
749array
750+0.984584630, +0.548526406, +0.801217854, +0.934136748, +0.532863557, +0.834214330, +0.347375393
751count = getUnifRand(0, size(array))
752count
753+1
754array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
755array
756+0.984584630
757
758count = getUnifRand(4, 10)
759array = getUnifRand(0., 1., count) ! generate random array for illustration.
760array
761+0.662213027, +0.591104627E-1, +0.463947833, +0.664843857, +0.917766273, +0.499189675, +0.693770647E-1, +0.701038361, +0.606510937, +0.306886435E-1
762array = getShuffled(array)
763array
764+0.499189675, +0.664843857, +0.701038361, +0.591104627E-1, +0.306886435E-1, +0.693770647E-1, +0.606510937, +0.917766273, +0.463947833, +0.662213027
765count = getUnifRand(0, size(array))
766count
767+3
768array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
769array
770+0.701038361, +0.662213027, +0.693770647E-1
771
772count = getUnifRand(4, 10)
773array = getUnifRand(0., 1., count) ! generate random array for illustration.
774array
775+0.402232409, +0.113128424, +0.982472301E-1, +0.414122880, +0.144274533, +0.527621746, +0.978948355, +0.765560031, +0.121542394
776array = getShuffled(array)
777array
778+0.113128424, +0.765560031, +0.527621746, +0.144274533, +0.402232409, +0.121542394, +0.982472301E-1, +0.978948355, +0.414122880
779count = getUnifRand(0, size(array))
780count
781+2
782array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
783array
784+0.765560031, +0.402232409
785
786count = getUnifRand(4, 10)
787array = getUnifRand(0., 1., count) ! generate random array for illustration.
788array
789+0.126401901, +0.409725308, +0.290748894, +0.746052206, +0.638841391E-1, +0.621300340E-1, +0.121626973, +0.372182906, +0.519970298
790array = getShuffled(array)
791array
792+0.290748894, +0.746052206, +0.621300340E-1, +0.638841391E-1, +0.126401901, +0.519970298, +0.372182906, +0.409725308, +0.121626973
793count = getUnifRand(0, size(array))
794count
795+4
796array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
797array
798+0.126401901, +0.638841391E-1, +0.290748894, +0.121626973
799
800count = getUnifRand(4, 10)
801array = getUnifRand(0., 1., count) ! generate random array for illustration.
802array
803+0.734670043, +0.172342002, +0.456180871, +0.818909645
804array = getShuffled(array)
805array
806+0.734670043, +0.818909645, +0.456180871, +0.172342002
807count = getUnifRand(0, size(array))
808count
809+2
810array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
811array
812+0.456180871, +0.818909645
813
814count = getUnifRand(4, 10)
815array = getUnifRand(0., 1., count) ! generate random array for illustration.
816array
817+0.359283090, +0.580518842E-1, +0.714211226, +0.970433891, +0.956873477, +0.959856868, +0.826061428, +0.260433555, +0.383478105
818array = getShuffled(array)
819array
820+0.970433891, +0.260433555, +0.383478105, +0.959856868, +0.956873477, +0.359283090, +0.826061428, +0.714211226, +0.580518842E-1
821count = getUnifRand(0, size(array))
822count
823+8
824array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
825array
826+0.260433555, +0.714211226, +0.359283090, +0.956873477, +0.959856868, +0.580518842E-1, +0.970433891, +0.826061428
827
828count = getUnifRand(4, 10)
829array = getUnifRand(0., 1., count) ! generate random array for illustration.
830array
831+0.369260490, +0.139049888, +0.495823562, +0.131693840, +0.219791591
832array = getShuffled(array)
833array
834+0.219791591, +0.131693840, +0.369260490, +0.495823562, +0.139049888
835count = getUnifRand(0, size(array))
836count
837+5
838array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
839array
840+0.219791591, +0.369260490, +0.495823562, +0.139049888, +0.131693840
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 Austin

Definition at line 145 of file pm_arrayShuffle.F90.


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