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"TDGYUPCRXD"
6array = getShuffled(array)
7array
8"XDDYTRUGCP"
9count = getUnifRand(0, len(array))
10count
11+3
12array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
13array
14"DUD"
15
16count = getUnifRand(4, 10)
17array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
18array
19"RGLDP"
20array = getShuffled(array)
21array
22"DLPGR"
23count = getUnifRand(0, len(array))
24count
25+2
26array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
27array
28"RD"
29
30count = getUnifRand(4, 10)
31array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
32array
33"NDQTZQJ"
34array = getShuffled(array)
35array
36"ZJQTQDN"
37count = getUnifRand(0, len(array))
38count
39+2
40array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
41array
42"TD"
43
44count = getUnifRand(4, 10)
45array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
46array
47"OKJDQSL"
48array = getShuffled(array)
49array
50"SOLDJKQ"
51count = getUnifRand(0, len(array))
52count
53+4
54array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
55array
56"KSJL"
57
58count = getUnifRand(4, 10)
59array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
60array
61"ACADLXVTIB"
62array = getShuffled(array)
63array
64"IVAXBTALCD"
65count = getUnifRand(0, len(array))
66count
67+7
68array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
69array
70"CADBTXL"
71
72count = getUnifRand(4, 10)
73array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
74array
75"BEWQIYW"
76array = getShuffled(array)
77array
78"BWYEIQW"
79count = getUnifRand(0, len(array))
80count
81+3
82array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
83array
84"WQB"
85
86count = getUnifRand(4, 10)
87array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
88array
89"AONUABJB"
90array = getShuffled(array)
91array
92"JABNUOAB"
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"HAXLYNL"
104array = getShuffled(array)
105array
106"XNYALLH"
107count = getUnifRand(0, len(array))
108count
109+6
110array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
111array
112"XYHNLA"
113
114count = getUnifRand(4, 10)
115array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
116array
117"BWTMBB"
118array = getShuffled(array)
119array
120"WBTBBM"
121count = getUnifRand(0, len(array))
122count
123+6
124array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
125array
126"BTBBWM"
127
128count = getUnifRand(4, 10)
129array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
130array
131"EPSQXPOUQ"
132array = getShuffled(array)
133array
134"OPQQESUXP"
135count = getUnifRand(0, len(array))
136count
137+3
138array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
139array
140"OPQ"
141
142count = getUnifRand(4, 10)
143array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
144array
145"NE", "MP", "BE", "JP", "LY", "RU", "EL", "LX", "SX"
146array = getShuffled(array)
147array
148"JP", "BE", "MP", "NE", "EL", "LX", "LY", "RU", "SX"
149count = getUnifRand(0, size(array))
150count
151+5
152array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
153array
154"RU", "LY", "MP", "EL", "SX"
155
156count = getUnifRand(4, 10)
157array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
158array
159"KE", "IP", "ME", "OX", "DD", "YF"
160array = getShuffled(array)
161array
162"ME", "OX", "IP", "DD", "KE", "YF"
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"UY", "JO", "WZ", "WF", "NH"
174array = getShuffled(array)
175array
176"UY", "WF", "WZ", "JO", "NH"
177count = getUnifRand(0, size(array))
178count
179+2
180array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
181array
182"NH", "JO"
183
184count = getUnifRand(4, 10)
185array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
186array
187"LF", "JC", "QU", "MC", "KY", "BG", "EN"
188array = getShuffled(array)
189array
190"MC", "QU", "JC", "KY", "BG", "EN", "LF"
191count = getUnifRand(0, size(array))
192count
193+4
194array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
195array
196"QU", "KY", "BG", "LF"
197
198count = getUnifRand(4, 10)
199array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
200array
201"GB", "UP", "HW", "HS", "PQ", "KK", "KD", "GV", "CL"
202array = getShuffled(array)
203array
204"HW", "HS", "GV", "CL", "PQ", "GB", "KK", "KD", "UP"
205count = getUnifRand(0, size(array))
206count
207+6
208array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
209array
210"GV", "UP", "CL", "KK", "GB", "HS"
211
212count = getUnifRand(4, 10)
213array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
214array
215"DV", "FM", "YT", "NK", "YC", "LD"
216array = getShuffled(array)
217array
218"DV", "YT", "YC", "LD", "FM", "NK"
219count = getUnifRand(0, size(array))
220count
221+1
222array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
223array
224"NK"
225
226count = getUnifRand(4, 10)
227array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
228array
229"VV", "BC", "MP", "MK", "EP", "RR", "XP", "PT"
230array = getShuffled(array)
231array
232"BC", "RR", "PT", "MK", "MP", "EP", "VV", "XP"
233count = getUnifRand(0, size(array))
234count
235+1
236array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
237array
238"PT"
239
240count = getUnifRand(4, 10)
241array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
242array
243"BW", "BH", "YG", "RE", "TF", "BD"
244array = getShuffled(array)
245array
246"BH", "BD", "RE", "YG", "TF", "BW"
247count = getUnifRand(0, size(array))
248count
249+4
250array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
251array
252"TF", "RE", "BH", "BW"
253
254count = getUnifRand(4, 10)
255array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
256array
257"KM", "YM", "PY", "JN", "DQ", "AY", "FD", "WN", "BD"
258array = getShuffled(array)
259array
260"PY", "WN", "JN", "YM", "KM", "BD", "AY", "DQ", "FD"
261count = getUnifRand(0, size(array))
262count
263+1
264array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
265array
266"WN"
267
268count = getUnifRand(4, 10)
269array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
270array
271"WV", "QX", "CZ", "BI", "QA"
272array = getShuffled(array)
273array
274"CZ", "QA", "QX", "WV", "BI"
275count = getUnifRand(0, size(array))
276count
277+5
278array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
279array
280"BI", "CZ", "WV", "QA", "QX"
281
282count = getUnifRand(4, 10)
283array = getUnifRand(0, 9, count) ! generate random array for illustration.
284array
285+2, +8, +1, +3, +3
286array = getShuffled(array)
287array
288+3, +2, +3, +8, +1
289count = getUnifRand(0, size(array))
290count
291+1
292array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
293array
294+3
295
296count = getUnifRand(4, 10)
297array = getUnifRand(0, 9, count) ! generate random array for illustration.
298array
299+6, +0, +1, +1, +5
300array = getShuffled(array)
301array
302+1, +0, +1, +6, +5
303count = getUnifRand(0, size(array))
304count
305+2
306array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
307array
308+0, +1
309
310count = getUnifRand(4, 10)
311array = getUnifRand(0, 9, count) ! generate random array for illustration.
312array
313+3, +0, +0, +8, +1, +7, +6
314array = getShuffled(array)
315array
316+1, +8, +0, +6, +3, +7, +0
317count = getUnifRand(0, size(array))
318count
319+1
320array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
321array
322+0
323
324count = getUnifRand(4, 10)
325array = getUnifRand(0, 9, count) ! generate random array for illustration.
326array
327+0, +2, +9, +0, +7, +4
328array = getShuffled(array)
329array
330+7, +0, +0, +4, +9, +2
331count = getUnifRand(0, size(array))
332count
333+6
334array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
335array
336+7, +9, +0, +0, +2, +4
337
338count = getUnifRand(4, 10)
339array = getUnifRand(0, 9, count) ! generate random array for illustration.
340array
341+4, +5, +2, +2, +9, +0, +2, +7, +4
342array = getShuffled(array)
343array
344+2, +7, +9, +4, +5, +2, +4, +0, +2
345count = getUnifRand(0, size(array))
346count
347+0
348array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
349array
350
351
352count = getUnifRand(4, 10)
353array = getUnifRand(0, 9, count) ! generate random array for illustration.
354array
355+7, +2, +6, +4
356array = getShuffled(array)
357array
358+2, +7, +4, +6
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+0, +9, +7, +0
370array = getShuffled(array)
371array
372+7, +0, +9, +0
373count = getUnifRand(0, size(array))
374count
375+0
376array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
377array
378
379
380count = getUnifRand(4, 10)
381array = getUnifRand(0, 9, count) ! generate random array for illustration.
382array
383+9, +2, +0, +5, +9
384array = getShuffled(array)
385array
386+0, +5, +9, +9, +2
387count = getUnifRand(0, size(array))
388count
389+1
390array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
391array
392+0
393
394count = getUnifRand(4, 10)
395array = getUnifRand(0, 9, count) ! generate random array for illustration.
396array
397+3, +9, +4, +7, +7, +9
398array = getShuffled(array)
399array
400+9, +4, +7, +9, +3, +7
401count = getUnifRand(0, size(array))
402count
403+4
404array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
405array
406+9, +7, +3, +9
407
408count = getUnifRand(4, 10)
409array = getUnifRand(0, 9, count) ! generate random array for illustration.
410array
411+5, +7, +2, +9, +0, +6, +8
412array = getShuffled(array)
413array
414+0, +7, +5, +9, +2, +8, +6
415count = getUnifRand(0, size(array))
416count
417+5
418array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
419array
420+6, +5, +2, +7, +9
421
422count = getUnifRand(4, 10)
423array = getUnifRand(.false., .true., count) ! generate random array for illustration.
424array
425F, T, T, T, F, T, T
426array = getShuffled(array)
427array
428F, T, T, T, F, T, T
429count = getUnifRand(0, size(array))
430count
431+2
432array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
433array
434F, T
435
436count = getUnifRand(4, 10)
437array = getUnifRand(.false., .true., count) ! generate random array for illustration.
438array
439F, F, T, T, F, T, T
440array = getShuffled(array)
441array
442F, F, T, T, F, T, T
443count = getUnifRand(0, size(array))
444count
445+3
446array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
447array
448T, F, T
449
450count = getUnifRand(4, 10)
451array = getUnifRand(.false., .true., count) ! generate random array for illustration.
452array
453F, F, F, F, F, T
454array = getShuffled(array)
455array
456F, T, F, F, F, F
457count = getUnifRand(0, size(array))
458count
459+6
460array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
461array
462F, F, F, F, F, T
463
464count = getUnifRand(4, 10)
465array = getUnifRand(.false., .true., count) ! generate random array for illustration.
466array
467F, F, F, F, F, F
468array = getShuffled(array)
469array
470F, F, F, F, F, F
471count = getUnifRand(0, size(array))
472count
473+2
474array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
475array
476F, F
477
478count = getUnifRand(4, 10)
479array = getUnifRand(.false., .true., count) ! generate random array for illustration.
480array
481F, T, T, T, F, T, F, T
482array = getShuffled(array)
483array
484T, F, T, T, T, F, F, T
485count = getUnifRand(0, size(array))
486count
487+4
488array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
489array
490T, T, T, F
491
492count = getUnifRand(4, 10)
493array = getUnifRand(.false., .true., count) ! generate random array for illustration.
494array
495T, F, T, T
496array = getShuffled(array)
497array
498T, T, F, T
499count = getUnifRand(0, size(array))
500count
501+3
502array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
503array
504F, T, T
505
506count = getUnifRand(4, 10)
507array = getUnifRand(.false., .true., count) ! generate random array for illustration.
508array
509F, F, T, F
510array = getShuffled(array)
511array
512T, F, F, F
513count = getUnifRand(0, size(array))
514count
515+1
516array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
517array
518F
519
520count = getUnifRand(4, 10)
521array = getUnifRand(.false., .true., count) ! generate random array for illustration.
522array
523F, T, T, F, F
524array = getShuffled(array)
525array
526F, F, T, T, F
527count = getUnifRand(0, size(array))
528count
529+5
530array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
531array
532F, T, T, F, F
533
534count = getUnifRand(4, 10)
535array = getUnifRand(.false., .true., count) ! generate random array for illustration.
536array
537F, F, T, F, F
538array = getShuffled(array)
539array
540T, F, F, F, F
541count = getUnifRand(0, size(array))
542count
543+5
544array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
545array
546F, F, T, F, F
547
548count = getUnifRand(4, 10)
549array = getUnifRand(.false., .true., count) ! generate random array for illustration.
550array
551T, T, T, T, F, T, F, F, F, T
552array = getShuffled(array)
553array
554F, F, F, T, T, T, T, T, T, F
555count = getUnifRand(0, size(array))
556count
557+10
558array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
559array
560F, T, F, T, T, F, T, T, F, T
561
562count = getUnifRand(4, 10)
563array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
564array
565(+0.317192912, +0.452004731), (+0.466819406E-1, +0.535630465), (+0.746624351, +0.253590763), (+0.100054741, +0.588546693), (+0.677329004, +0.288229167)
566array = getShuffled(array)
567array
568(+0.466819406E-1, +0.535630465), (+0.677329004, +0.288229167), (+0.746624351, +0.253590763), (+0.317192912, +0.452004731), (+0.100054741, +0.588546693)
569count = getUnifRand(0, size(array))
570count
571+4
572array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
573array
574(+0.317192912, +0.452004731), (+0.746624351, +0.253590763), (+0.100054741, +0.588546693), (+0.677329004, +0.288229167)
575
576count = getUnifRand(4, 10)
577array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
578array
579(+0.627189517, +0.626557350), (+0.350541949, +0.108194530), (+0.867333353, +0.347411096), (+0.793159008E-1, +0.323844016), (+0.411503077, +0.573862970)
580array = getShuffled(array)
581array
582(+0.627189517, +0.626557350), (+0.350541949, +0.108194530), (+0.793159008E-1, +0.323844016), (+0.411503077, +0.573862970), (+0.867333353, +0.347411096)
583count = getUnifRand(0, size(array))
584count
585+4
586array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
587array
588(+0.627189517, +0.626557350), (+0.350541949, +0.108194530), (+0.411503077, +0.573862970), (+0.867333353, +0.347411096)
589
590count = getUnifRand(4, 10)
591array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
592array
593(+0.800109386, +0.591072857), (+0.801631153, +0.318058193), (+0.590119243, +0.991975427), (+0.128134310, +0.992570817), (+0.797223270, +0.364309847), (+0.929321766, +0.371339321E-1), (+0.456440628, +0.284176469E-1), (+0.492525935, +0.660563946), (+0.157333076, +0.718464315)
594array = getShuffled(array)
595array
596(+0.929321766, +0.371339321E-1), (+0.590119243, +0.991975427), (+0.456440628, +0.284176469E-1), (+0.801631153, +0.318058193), (+0.128134310, +0.992570817), (+0.492525935, +0.660563946), (+0.797223270, +0.364309847), (+0.157333076, +0.718464315), (+0.800109386, +0.591072857)
597count = getUnifRand(0, size(array))
598count
599+7
600array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
601array
602(+0.157333076, +0.718464315), (+0.801631153, +0.318058193), (+0.590119243, +0.991975427), (+0.929321766, +0.371339321E-1), (+0.128134310, +0.992570817), (+0.800109386, +0.591072857), (+0.456440628, +0.284176469E-1)
603
604count = getUnifRand(4, 10)
605array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
606array
607(+0.268506885, +0.842541873), (+0.292266250, +0.547934651), (+0.889964104E-1, +0.612549067), (+0.383528292, +0.308706939), (+0.678492367, +0.602693021)
608array = getShuffled(array)
609array
610(+0.292266250, +0.547934651), (+0.678492367, +0.602693021), (+0.268506885, +0.842541873), (+0.889964104E-1, +0.612549067), (+0.383528292, +0.308706939)
611count = getUnifRand(0, size(array))
612count
613+2
614array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
615array
616(+0.268506885, +0.842541873), (+0.292266250, +0.547934651)
617
618count = getUnifRand(4, 10)
619array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
620array
621(+0.103776872, +0.240086854), (+0.970195055, +0.658509731E-1), (+0.921001732, +0.495144069), (+0.355695903, +0.881768525), (+0.946150005, +0.132198870), (+0.644226134, +0.982109368)
622array = getShuffled(array)
623array
624(+0.355695903, +0.881768525), (+0.946150005, +0.132198870), (+0.970195055, +0.658509731E-1), (+0.644226134, +0.982109368), (+0.103776872, +0.240086854), (+0.921001732, +0.495144069)
625count = getUnifRand(0, size(array))
626count
627+0
628array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
629array
630
631
632count = getUnifRand(4, 10)
633array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
634array
635(+0.739241838, +0.973634601), (+0.914921701, +0.527829349), (+0.708583951, +0.253438652), (+0.187454104, +0.181678116), (+0.912250280, +0.260435283), (+0.507740319, +0.548435032)
636array = getShuffled(array)
637array
638(+0.912250280, +0.260435283), (+0.708583951, +0.253438652), (+0.507740319, +0.548435032), (+0.914921701, +0.527829349), (+0.739241838, +0.973634601), (+0.187454104, +0.181678116)
639count = getUnifRand(0, size(array))
640count
641+5
642array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
643array
644(+0.507740319, +0.548435032), (+0.708583951, +0.253438652), (+0.187454104, +0.181678116), (+0.914921701, +0.527829349), (+0.912250280, +0.260435283)
645
646count = getUnifRand(4, 10)
647array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
648array
649(+0.502084434, +0.210427165), (+0.409773290, +0.936624229), (+0.197861969, +0.134814382), (+0.757906020, +0.993931711), (+0.723881960, +0.726955235), (+0.484842420, +0.380497873), (+0.526067853, +0.643285692), (+0.182982564, +0.572760880), (+0.778287649, +0.137004137)
650array = getShuffled(array)
651array
652(+0.526067853, +0.643285692), (+0.409773290, +0.936624229), (+0.197861969, +0.134814382), (+0.182982564, +0.572760880), (+0.502084434, +0.210427165), (+0.757906020, +0.993931711), (+0.723881960, +0.726955235), (+0.484842420, +0.380497873), (+0.778287649, +0.137004137)
653count = getUnifRand(0, size(array))
654count
655+8
656array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
657array
658(+0.757906020, +0.993931711), (+0.197861969, +0.134814382), (+0.484842420, +0.380497873), (+0.409773290, +0.936624229), (+0.182982564, +0.572760880), (+0.778287649, +0.137004137), (+0.526067853, +0.643285692), (+0.502084434, +0.210427165)
659
660count = getUnifRand(4, 10)
661array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
662array
663(+0.886510611E-1, +0.992991388), (+0.789501190, +0.280396342), (+0.898063779E-1, +0.982242048), (+0.263778865, +0.479088366), (+0.934063435, +0.237498283), (+0.622903943, +0.437605500), (+0.854397178, +0.220434606), (+0.125190616E-1, +0.277341366), (+0.349693120, +0.878956735), (+0.484167159, +0.780246854E-1)
664array = getShuffled(array)
665array
666(+0.898063779E-1, +0.982242048), (+0.349693120, +0.878956735), (+0.789501190, +0.280396342), (+0.484167159, +0.780246854E-1), (+0.934063435, +0.237498283), (+0.125190616E-1, +0.277341366), (+0.622903943, +0.437605500), (+0.854397178, +0.220434606), (+0.263778865, +0.479088366), (+0.886510611E-1, +0.992991388)
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.236724019E-1, +0.206309617), (+0.784792423, +0.701056242), (+0.659558713, +0.709384382), (+0.407980680, +0.434190035E-1), (+0.448650718E-1, +0.285369158E-2), (+0.475870371E-1, +0.148730755)
678array = getShuffled(array)
679array
680(+0.236724019E-1, +0.206309617), (+0.659558713, +0.709384382), (+0.407980680, +0.434190035E-1), (+0.448650718E-1, +0.285369158E-2), (+0.475870371E-1, +0.148730755), (+0.784792423, +0.701056242)
681count = getUnifRand(0, size(array))
682count
683+1
684array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
685array
686(+0.407980680, +0.434190035E-1)
687
688count = getUnifRand(4, 10)
689array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
690array
691(+0.839085281, +0.123452783), (+0.944589078, +0.498986244E-2), (+0.358630538, +0.646822095), (+0.113746524E-1, +0.358310759), (+0.598113775, +0.764192820), (+0.374714136E-1, +0.931995034), (+0.282228589, +0.686004162), (+0.464748204, +0.542207599), (+0.156427205, +0.587688148), (+0.261585593, +0.981818080)
692array = getShuffled(array)
693array
694(+0.282228589, +0.686004162), (+0.839085281, +0.123452783), (+0.358630538, +0.646822095), (+0.374714136E-1, +0.931995034), (+0.113746524E-1, +0.358310759), (+0.261585593, +0.981818080), (+0.464748204, +0.542207599), (+0.156427205, +0.587688148), (+0.944589078, +0.498986244E-2), (+0.598113775, +0.764192820)
695count = getUnifRand(0, size(array))
696count
697+0
698array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
699array
700
701
702count = getUnifRand(4, 10)
703array = getUnifRand(0., 1., count) ! generate random array for illustration.
704array
705+0.103490829, +0.655597150, +0.685547829, +0.353487313, +0.402303278
706array = getShuffled(array)
707array
708+0.655597150, +0.103490829, +0.402303278, +0.353487313, +0.685547829
709count = getUnifRand(0, size(array))
710count
711+5
712array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
713array
714+0.353487313, +0.685547829, +0.402303278, +0.655597150, +0.103490829
715
716count = getUnifRand(4, 10)
717array = getUnifRand(0., 1., count) ! generate random array for illustration.
718array
719+0.387106895, +0.118154466, +0.875806689, +0.977987826, +0.548606992, +0.773658752E-1, +0.602793932, +0.881369829, +0.121393085
720array = getShuffled(array)
721array
722+0.875806689, +0.881369829, +0.548606992, +0.118154466, +0.977987826, +0.602793932, +0.121393085, +0.387106895, +0.773658752E-1
723count = getUnifRand(0, size(array))
724count
725+6
726array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
727array
728+0.118154466, +0.602793932, +0.881369829, +0.875806689, +0.977987826, +0.548606992
729
730count = getUnifRand(4, 10)
731array = getUnifRand(0., 1., count) ! generate random array for illustration.
732array
733+0.262931287, +0.408133626, +0.978778064, +0.237863123, +0.134969592, +0.851609111E-1, +0.935131133
734array = getShuffled(array)
735array
736+0.851609111E-1, +0.134969592, +0.408133626, +0.978778064, +0.237863123, +0.262931287, +0.935131133
737count = getUnifRand(0, size(array))
738count
739+4
740array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
741array
742+0.935131133, +0.408133626, +0.134969592, +0.237863123
743
744count = getUnifRand(4, 10)
745array = getUnifRand(0., 1., count) ! generate random array for illustration.
746array
747+0.655021429, +0.996480525, +0.936402678E-1, +0.805007517, +0.296100855
748array = getShuffled(array)
749array
750+0.296100855, +0.655021429, +0.805007517, +0.936402678E-1, +0.996480525
751count = getUnifRand(0, size(array))
752count
753+3
754array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
755array
756+0.805007517, +0.655021429, +0.296100855
757
758count = getUnifRand(4, 10)
759array = getUnifRand(0., 1., count) ! generate random array for illustration.
760array
761+0.330810905, +0.421787620, +0.204466879, +0.547792435, +0.461079061
762array = getShuffled(array)
763array
764+0.421787620, +0.330810905, +0.461079061, +0.204466879, +0.547792435
765count = getUnifRand(0, size(array))
766count
767+1
768array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
769array
770+0.461079061
771
772count = getUnifRand(4, 10)
773array = getUnifRand(0., 1., count) ! generate random array for illustration.
774array
775+0.719959497, +0.146506131, +0.380503774, +0.189287484
776array = getShuffled(array)
777array
778+0.146506131, +0.189287484, +0.719959497, +0.380503774
779count = getUnifRand(0, size(array))
780count
781+4
782array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
783array
784+0.189287484, +0.380503774, +0.719959497, +0.146506131
785
786count = getUnifRand(4, 10)
787array = getUnifRand(0., 1., count) ! generate random array for illustration.
788array
789+0.868238509, +0.521131754E-1, +0.312158465, +0.729215860, +0.423000932, +0.287313998, +0.500873625, +0.176197290E-2, +0.209888756
790array = getShuffled(array)
791array
792+0.868238509, +0.729215860, +0.500873625, +0.209888756, +0.287313998, +0.521131754E-1, +0.312158465, +0.176197290E-2, +0.423000932
793count = getUnifRand(0, size(array))
794count
795+8
796array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
797array
798+0.500873625, +0.209888756, +0.868238509, +0.176197290E-2, +0.423000932, +0.729215860, +0.312158465, +0.521131754E-1
799
800count = getUnifRand(4, 10)
801array = getUnifRand(0., 1., count) ! generate random array for illustration.
802array
803+0.299190223, +0.187425673, +0.104011893, +0.820688009, +0.163405240, +0.657234788E-1
804array = getShuffled(array)
805array
806+0.163405240, +0.104011893, +0.657234788E-1, +0.820688009, +0.187425673, +0.299190223
807count = getUnifRand(0, size(array))
808count
809+5
810array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
811array
812+0.657234788E-1, +0.820688009, +0.187425673, +0.163405240, +0.104011893
813
814count = getUnifRand(4, 10)
815array = getUnifRand(0., 1., count) ! generate random array for illustration.
816array
817+0.977609038, +0.629142880, +0.747443914, +0.999770164, +0.361863971, +0.937482715E-1, +0.915633440
818array = getShuffled(array)
819array
820+0.629142880, +0.999770164, +0.747443914, +0.361863971, +0.937482715E-1, +0.915633440, +0.977609038
821count = getUnifRand(0, size(array))
822count
823+7
824array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
825array
826+0.629142880, +0.915633440, +0.747443914, +0.937482715E-1, +0.999770164, +0.977609038, +0.361863971
827
828count = getUnifRand(4, 10)
829array = getUnifRand(0., 1., count) ! generate random array for illustration.
830array
831+0.634543538, +0.430700958, +0.202026963E-1, +0.550926208
832array = getShuffled(array)
833array
834+0.550926208, +0.430700958, +0.202026963E-1, +0.634543538
835count = getUnifRand(0, size(array))
836count
837+0
838array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
839array
840
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: