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"ZPERVO"
6array = getShuffled(array)
7array
8"RVOEPZ"
9count = getUnifRand(0, len(array))
10count
11+0
12array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
13array
14""
15
16count = getUnifRand(4, 10)
17array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
18array
19"CFWRUKKV"
20array = getShuffled(array)
21array
22"KVKFUCRW"
23count = getUnifRand(0, len(array))
24count
25+5
26array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
27array
28"KVFUW"
29
30count = getUnifRand(4, 10)
31array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
32array
33"LKZYV"
34array = getShuffled(array)
35array
36"LZYVK"
37count = getUnifRand(0, len(array))
38count
39+4
40array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
41array
42"KLYV"
43
44count = getUnifRand(4, 10)
45array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
46array
47"LKAP"
48array = getShuffled(array)
49array
50"KLPA"
51count = getUnifRand(0, len(array))
52count
53+2
54array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
55array
56"AK"
57
58count = getUnifRand(4, 10)
59array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
60array
61"HWNBXRMEM"
62array = getShuffled(array)
63array
64"XEHMNWRBM"
65count = getUnifRand(0, len(array))
66count
67+7
68array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
69array
70"REMWNXB"
71
72count = getUnifRand(4, 10)
73array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
74array
75"KDMI"
76array = getShuffled(array)
77array
78"KMDI"
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"WZGI"
90array = getShuffled(array)
91array
92"ZIGW"
93count = getUnifRand(0, len(array))
94count
95+3
96array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
97array
98"WIZ"
99
100count = getUnifRand(4, 10)
101array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
102array
103"LRJQZAQ"
104array = getShuffled(array)
105array
106"QAZLQRJ"
107count = getUnifRand(0, len(array))
108count
109+3
110array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
111array
112"JLQ"
113
114count = getUnifRand(4, 10)
115array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
116array
117"EXTCCSCGJ"
118array = getShuffled(array)
119array
120"SCTEJXCGC"
121count = getUnifRand(0, len(array))
122count
123+9
124array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
125array
126"CJSXEGCCT"
127
128count = getUnifRand(4, 10)
129array = getUnifRand(repeat('A', count), repeat('Z', count)) ! generate random array for illustration.
130array
131"RMOIY"
132array = getShuffled(array)
133array
134"MYORI"
135count = getUnifRand(0, len(array))
136count
137+0
138array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
139array
140""
141
142count = getUnifRand(4, 10)
143array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
144array
145"GK", "CL", "TT", "ZX", "NR", "RM", "XX", "BD", "OW"
146array = getShuffled(array)
147array
148"ZX", "NR", "RM", "GK", "XX", "BD", "CL", "TT", "OW"
149count = getUnifRand(0, size(array))
150count
151+4
152array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
153array
154"RM", "XX", "NR", "BD"
155
156count = getUnifRand(4, 10)
157array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
158array
159"DZ", "JK", "ZY", "BX", "NW", "NY"
160array = getShuffled(array)
161array
162"ZY", "NW", "NY", "JK", "BX", "DZ"
163count = getUnifRand(0, size(array))
164count
165+1
166array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
167array
168"JK"
169
170count = getUnifRand(4, 10)
171array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
172array
173"OA", "AL", "VT", "ZV"
174array = getShuffled(array)
175array
176"VT", "AL", "ZV", "OA"
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"KX", "LT", "SE", "EQ", "SN", "HI", "YZ", "UP", "QW", "SU"
188array = getShuffled(array)
189array
190"YZ", "SU", "LT", "UP", "QW", "KX", "EQ", "SE", "SN", "HI"
191count = getUnifRand(0, size(array))
192count
193+5
194array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
195array
196"YZ", "QW", "SE", "SN", "SU"
197
198count = getUnifRand(4, 10)
199array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
200array
201"MH", "PV", "AR", "SR", "SG", "FC", "TJ", "ND", "OL", "CX"
202array = getShuffled(array)
203array
204"ND", "OL", "SR", "PV", "FC", "AR", "SG", "MH", "CX", "TJ"
205count = getUnifRand(0, size(array))
206count
207+6
208array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
209array
210"AR", "SR", "TJ", "ND", "MH", "FC"
211
212count = getUnifRand(4, 10)
213array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
214array
215"IS", "BV", "IB", "NB", "YV", "VZ", "LL"
216array = getShuffled(array)
217array
218"LL", "VZ", "IB", "BV", "YV", "IS", "NB"
219count = getUnifRand(0, size(array))
220count
221+3
222array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
223array
224"YV", "NB", "IS"
225
226count = getUnifRand(4, 10)
227array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
228array
229"FV", "TM", "KD", "NE", "ZH", "XS", "WZ", "BL"
230array = getShuffled(array)
231array
232"NE", "BL", "FV", "XS", "TM", "WZ", "ZH", "KD"
233count = getUnifRand(0, size(array))
234count
235+7
236array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
237array
238"NE", "KD", "XS", "BL", "TM", "ZH", "WZ"
239
240count = getUnifRand(4, 10)
241array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
242array
243"LZ", "UY", "PI", "XK", "LT", "OT", "OJ", "HF"
244array = getShuffled(array)
245array
246"LT", "LZ", "UY", "PI", "OJ", "XK", "OT", "HF"
247count = getUnifRand(0, size(array))
248count
249+0
250array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
251array
252
253
254count = getUnifRand(4, 10)
255array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
256array
257"MM", "UL", "AE", "OA", "EX", "ME"
258array = getShuffled(array)
259array
260"OA", "ME", "MM", "EX", "AE", "UL"
261count = getUnifRand(0, size(array))
262count
263+2
264array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
265array
266"MM", "EX"
267
268count = getUnifRand(4, 10)
269array = getUnifRand('AA', 'ZZ', count) ! generate random array for illustration.
270array
271"FE", "IH", "TD", "XM", "KL", "ZM", "QH", "EA", "AG", "DQ"
272array = getShuffled(array)
273array
274"FE", "KL", "TD", "AG", "XM", "QH", "DQ", "EA", "IH", "ZM"
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, +0, +8, +8
286array = getShuffled(array)
287array
288+8, +1, +8, +0
289count = getUnifRand(0, size(array))
290count
291+2
292array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
293array
294+8, +0
295
296count = getUnifRand(4, 10)
297array = getUnifRand(0, 9, count) ! generate random array for illustration.
298array
299+2, +9, +1, +8, +9, +8, +3
300array = getShuffled(array)
301array
302+9, +9, +1, +3, +2, +8, +8
303count = getUnifRand(0, size(array))
304count
305+6
306array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
307array
308+9, +9, +3, +2, +1, +8
309
310count = getUnifRand(4, 10)
311array = getUnifRand(0, 9, count) ! generate random array for illustration.
312array
313+3, +1, +9, +3, +8
314array = getShuffled(array)
315array
316+8, +3, +9, +1, +3
317count = getUnifRand(0, size(array))
318count
319+4
320array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
321array
322+8, +1, +3, +3
323
324count = getUnifRand(4, 10)
325array = getUnifRand(0, 9, count) ! generate random array for illustration.
326array
327+6, +9, +1, +3, +5, +2, +7, +6, +3
328array = getShuffled(array)
329array
330+3, +1, +6, +9, +3, +7, +6, +5, +2
331count = getUnifRand(0, size(array))
332count
333+0
334array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
335array
336
337
338count = getUnifRand(4, 10)
339array = getUnifRand(0, 9, count) ! generate random array for illustration.
340array
341+5, +6, +1, +7, +4, +3, +4
342array = getShuffled(array)
343array
344+3, +5, +7, +6, +4, +1, +4
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+3, +8, +1, +0
356array = getShuffled(array)
357array
358+8, +1, +3, +0
359count = getUnifRand(0, size(array))
360count
361+1
362array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
363array
364+0
365
366count = getUnifRand(4, 10)
367array = getUnifRand(0, 9, count) ! generate random array for illustration.
368array
369+8, +8, +2, +9
370array = getShuffled(array)
371array
372+9, +8, +8, +2
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+6, +1, +7, +8, +6, +0, +3, +3, +7
384array = getShuffled(array)
385array
386+0, +3, +7, +3, +6, +6, +1, +8, +7
387count = getUnifRand(0, size(array))
388count
389+2
390array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
391array
392+8, +1
393
394count = getUnifRand(4, 10)
395array = getUnifRand(0, 9, count) ! generate random array for illustration.
396array
397+5, +6, +3, +3, +3, +8, +8, +4
398array = getShuffled(array)
399array
400+3, +8, +5, +6, +3, +8, +4, +3
401count = getUnifRand(0, size(array))
402count
403+0
404array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
405array
406
407
408count = getUnifRand(4, 10)
409array = getUnifRand(0, 9, count) ! generate random array for illustration.
410array
411+0, +4, +6, +6, +1, +7, +0
412array = getShuffled(array)
413array
414+7, +0, +6, +0, +1, +6, +4
415count = getUnifRand(0, size(array))
416count
417+7
418array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
419array
420+6, +0, +4, +7, +0, +1, +6
421
422count = getUnifRand(4, 10)
423array = getUnifRand(.false., .true., count) ! generate random array for illustration.
424array
425T, F, T, F, T, F, F, F, F
426array = getShuffled(array)
427array
428F, T, F, T, F, F, F, F, 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, T, T, F, F
440array = getShuffled(array)
441array
442F, T, T, T, T, F, T
443count = getUnifRand(0, size(array))
444count
445+7
446array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
447array
448T, T, F, T, T, T, F
449
450count = getUnifRand(4, 10)
451array = getUnifRand(.false., .true., count) ! generate random array for illustration.
452array
453T, F, F, T, F
454array = getShuffled(array)
455array
456T, T, F, F, F
457count = getUnifRand(0, size(array))
458count
459+3
460array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
461array
462F, T, F
463
464count = getUnifRand(4, 10)
465array = getUnifRand(.false., .true., count) ! generate random array for illustration.
466array
467F, T, T, F, F, F, F, T
468array = getShuffled(array)
469array
470F, T, T, T, F, F, F, F
471count = getUnifRand(0, size(array))
472count
473+4
474array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
475array
476F, F, T, F
477
478count = getUnifRand(4, 10)
479array = getUnifRand(.false., .true., count) ! generate random array for illustration.
480array
481F, T, F, T, F, F, F, F
482array = getShuffled(array)
483array
484F, F, F, T, F, T, F, F
485count = getUnifRand(0, size(array))
486count
487+6
488array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
489array
490T, T, F, F, F, F
491
492count = getUnifRand(4, 10)
493array = getUnifRand(.false., .true., count) ! generate random array for illustration.
494array
495F, F, T, F, F, T, T, T, T, T
496array = getShuffled(array)
497array
498T, T, T, T, T, T, F, F, F, F
499count = getUnifRand(0, size(array))
500count
501+8
502array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
503array
504T, F, T, T, T, T, T, F
505
506count = getUnifRand(4, 10)
507array = getUnifRand(.false., .true., count) ! generate random array for illustration.
508array
509T, F, T, T, F, F, F, F
510array = getShuffled(array)
511array
512F, F, T, F, F, F, T, T
513count = getUnifRand(0, size(array))
514count
515+4
516array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
517array
518T, F, T, F
519
520count = getUnifRand(4, 10)
521array = getUnifRand(.false., .true., count) ! generate random array for illustration.
522array
523T, F, F, T, T, F, F, F
524array = getShuffled(array)
525array
526F, F, T, F, T, F, T, F
527count = getUnifRand(0, size(array))
528count
529+6
530array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
531array
532F, T, F, F, F, T
533
534count = getUnifRand(4, 10)
535array = getUnifRand(.false., .true., count) ! generate random array for illustration.
536array
537F, T, T, F
538array = getShuffled(array)
539array
540F, T, T, F
541count = getUnifRand(0, size(array))
542count
543+1
544array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
545array
546F
547
548count = getUnifRand(4, 10)
549array = getUnifRand(.false., .true., count) ! generate random array for illustration.
550array
551F, F, T, F, T, T, F, F
552array = getShuffled(array)
553array
554T, F, T, F, T, F, F, F
555count = getUnifRand(0, size(array))
556count
557+8
558array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
559array
560F, T, F, T, F, F, T, F
561
562count = getUnifRand(4, 10)
563array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
564array
565(+0.158410311, +0.249162614), (+0.962772608, +0.657161117), (+0.855094552, +0.908091068E-1), (+0.415132999, +0.735569537), (+0.374867320E-1, +0.809567928), (+0.994844377, +0.871823311), (+0.752367795, +0.300103247), (+0.749092460, +0.524414659), (+0.581870079E-1, +0.747360647), (+0.681913972, +0.492492139)
566array = getShuffled(array)
567array
568(+0.752367795, +0.300103247), (+0.158410311, +0.249162614), (+0.374867320E-1, +0.809567928), (+0.415132999, +0.735569537), (+0.962772608, +0.657161117), (+0.581870079E-1, +0.747360647), (+0.855094552, +0.908091068E-1), (+0.994844377, +0.871823311), (+0.749092460, +0.524414659), (+0.681913972, +0.492492139)
569count = getUnifRand(0, size(array))
570count
571+7
572array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
573array
574(+0.158410311, +0.249162614), (+0.994844377, +0.871823311), (+0.752367795, +0.300103247), (+0.855094552, +0.908091068E-1), (+0.962772608, +0.657161117), (+0.374867320E-1, +0.809567928), (+0.681913972, +0.492492139)
575
576count = getUnifRand(4, 10)
577array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
578array
579(+0.833932638, +0.878612936), (+0.697954834, +0.661129296), (+0.661052227, +0.117702961), (+0.581546724, +0.810290754), (+0.465370238, +0.679111063), (+0.297082007, +0.498380125)
580array = getShuffled(array)
581array
582(+0.833932638, +0.878612936), (+0.697954834, +0.661129296), (+0.465370238, +0.679111063), (+0.581546724, +0.810290754), (+0.297082007, +0.498380125), (+0.661052227, +0.117702961)
583count = getUnifRand(0, size(array))
584count
585+0
586array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
587array
588
589
590count = getUnifRand(4, 10)
591array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
592array
593(+0.610249221, +0.690998971), (+0.280198395, +0.602822363), (+0.193591416, +0.737349212), (+0.814382195, +0.261111856), (+0.406863511, +0.485967636), (+0.886841595, +0.869548321E-1), (+0.251714885, +0.971182823)
594array = getShuffled(array)
595array
596(+0.251714885, +0.971182823), (+0.610249221, +0.690998971), (+0.406863511, +0.485967636), (+0.886841595, +0.869548321E-1), (+0.193591416, +0.737349212), (+0.814382195, +0.261111856), (+0.280198395, +0.602822363)
597count = getUnifRand(0, size(array))
598count
599+5
600array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
601array
602(+0.814382195, +0.261111856), (+0.251714885, +0.971182823), (+0.406863511, +0.485967636), (+0.193591416, +0.737349212), (+0.610249221, +0.690998971)
603
604count = getUnifRand(4, 10)
605array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
606array
607(+0.346415281, +0.281436443), (+0.351047099, +0.243866384), (+0.591820240, +0.225287616), (+0.625212848, +0.874506950), (+0.400911629, +0.807475626), (+0.147639394, +0.630580425), (+0.531569242, +0.379311800), (+0.104012012, +0.919430971), (+0.483713686, +0.846499383), (+0.194289982, +0.352339029)
608array = getShuffled(array)
609array
610(+0.531569242, +0.379311800), (+0.625212848, +0.874506950), (+0.400911629, +0.807475626), (+0.483713686, +0.846499383), (+0.351047099, +0.243866384), (+0.147639394, +0.630580425), (+0.104012012, +0.919430971), (+0.591820240, +0.225287616), (+0.346415281, +0.281436443), (+0.194289982, +0.352339029)
611count = getUnifRand(0, size(array))
612count
613+6
614array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
615array
616(+0.351047099, +0.243866384), (+0.400911629, +0.807475626), (+0.194289982, +0.352339029), (+0.104012012, +0.919430971), (+0.483713686, +0.846499383), (+0.531569242, +0.379311800)
617
618count = getUnifRand(4, 10)
619array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
620array
621(+0.657308221, +0.518272936), (+0.162657142, +0.650136352), (+0.546666086, +0.281105697), (+0.451144397, +0.862596393)
622array = getShuffled(array)
623array
624(+0.451144397, +0.862596393), (+0.546666086, +0.281105697), (+0.162657142, +0.650136352), (+0.657308221, +0.518272936)
625count = getUnifRand(0, size(array))
626count
627+3
628array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
629array
630(+0.451144397, +0.862596393), (+0.657308221, +0.518272936), (+0.162657142, +0.650136352)
631
632count = getUnifRand(4, 10)
633array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
634array
635(+0.235408843, +0.661613762), (+0.700420856, +0.692327201), (+0.445427954, +0.258420527), (+0.643912554E-1, +0.562462270), (+0.245411932, +0.467551589), (+0.281917036, +0.234397948), (+0.617488027, +0.186720073), (+0.274779856, +0.825284064), (+0.804772019, +0.102105975), (+0.523745298, +0.954541266)
636array = getShuffled(array)
637array
638(+0.281917036, +0.234397948), (+0.643912554E-1, +0.562462270), (+0.617488027, +0.186720073), (+0.804772019, +0.102105975), (+0.235408843, +0.661613762), (+0.700420856, +0.692327201), (+0.274779856, +0.825284064), (+0.245411932, +0.467551589), (+0.445427954, +0.258420527), (+0.523745298, +0.954541266)
639count = getUnifRand(0, size(array))
640count
641+6
642array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
643array
644(+0.235408843, +0.661613762), (+0.445427954, +0.258420527), (+0.274779856, +0.825284064), (+0.643912554E-1, +0.562462270), (+0.245411932, +0.467551589), (+0.700420856, +0.692327201)
645
646count = getUnifRand(4, 10)
647array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
648array
649(+0.903897882, +0.562536478), (+0.559966147, +0.296862721E-1), (+0.683531940, +0.586902380), (+0.438271999, +0.991288662), (+0.900020719, +0.903334498), (+0.661156118, +0.120146215), (+0.758733153E-1, +0.205394030E-1), (+0.417031109, +0.602847934)
650array = getShuffled(array)
651array
652(+0.559966147, +0.296862721E-1), (+0.417031109, +0.602847934), (+0.900020719, +0.903334498), (+0.903897882, +0.562536478), (+0.438271999, +0.991288662), (+0.683531940, +0.586902380), (+0.661156118, +0.120146215), (+0.758733153E-1, +0.205394030E-1)
653count = getUnifRand(0, size(array))
654count
655+6
656array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
657array
658(+0.438271999, +0.991288662), (+0.661156118, +0.120146215), (+0.417031109, +0.602847934), (+0.683531940, +0.586902380), (+0.900020719, +0.903334498), (+0.903897882, +0.562536478)
659
660count = getUnifRand(4, 10)
661array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
662array
663(+0.405389607, +0.513545036), (+0.966439128, +0.948712766), (+0.341943443, +0.855357826), (+0.131749272, +0.785480142), (+0.140893102, +0.533472896E-1), (+0.926455975, +0.500228941)
664array = getShuffled(array)
665array
666(+0.405389607, +0.513545036), (+0.341943443, +0.855357826), (+0.966439128, +0.948712766), (+0.131749272, +0.785480142), (+0.926455975, +0.500228941), (+0.140893102, +0.533472896E-1)
667count = getUnifRand(0, size(array))
668count
669+1
670array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
671array
672(+0.140893102, +0.533472896E-1)
673
674count = getUnifRand(4, 10)
675array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
676array
677(+0.308763981E-2, +0.989409268), (+0.929836929, +0.987215877), (+0.677018225, +0.458018243), (+0.414575040, +0.176240206), (+0.748101890, +0.625330448), (+0.713483632, +0.313622236)
678array = getShuffled(array)
679array
680(+0.929836929, +0.987215877), (+0.748101890, +0.625330448), (+0.308763981E-2, +0.989409268), (+0.677018225, +0.458018243), (+0.713483632, +0.313622236), (+0.414575040, +0.176240206)
681count = getUnifRand(0, size(array))
682count
683+6
684array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
685array
686(+0.308763981E-2, +0.989409268), (+0.677018225, +0.458018243), (+0.929836929, +0.987215877), (+0.713483632, +0.313622236), (+0.414575040, +0.176240206), (+0.748101890, +0.625330448)
687
688count = getUnifRand(4, 10)
689array = getUnifRand((0., 0.), (1., 1.), count) ! generate random array for illustration.
690array
691(+0.314605594, +0.529682577), (+0.289498866, +0.412854493), (+0.472746849, +0.498557091E-1), (+0.219332337, +0.281960607), (+0.418564081, +0.830656528), (+0.157885790, +0.456436396), (+0.205911756, +0.358314931), (+0.960199535, +0.206587851)
692array = getShuffled(array)
693array
694(+0.472746849, +0.498557091E-1), (+0.418564081, +0.830656528), (+0.205911756, +0.358314931), (+0.157885790, +0.456436396), (+0.960199535, +0.206587851), (+0.314605594, +0.529682577), (+0.219332337, +0.281960607), (+0.289498866, +0.412854493)
695count = getUnifRand(0, size(array))
696count
697+7
698array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
699array
700(+0.205911756, +0.358314931), (+0.219332337, +0.281960607), (+0.289498866, +0.412854493), (+0.314605594, +0.529682577), (+0.157885790, +0.456436396), (+0.960199535, +0.206587851), (+0.418564081, +0.830656528)
701
702count = getUnifRand(4, 10)
703array = getUnifRand(0., 1., count) ! generate random array for illustration.
704array
705+0.842902362, +0.792556047, +0.839627922, +0.824748278E-1, +0.327917576
706array = getShuffled(array)
707array
708+0.327917576, +0.839627922, +0.824748278E-1, +0.842902362, +0.792556047
709count = getUnifRand(0, size(array))
710count
711+4
712array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
713array
714+0.839627922, +0.327917576, +0.842902362, +0.824748278E-1
715
716count = getUnifRand(4, 10)
717array = getUnifRand(0., 1., count) ! generate random array for illustration.
718array
719+0.223624110, +0.993391395, +0.271253288, +0.365105450, +0.756743193, +0.910860300E-2
720array = getShuffled(array)
721array
722+0.365105450, +0.756743193, +0.271253288, +0.993391395, +0.223624110, +0.910860300E-2
723count = getUnifRand(0, size(array))
724count
725+4
726array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
727array
728+0.756743193, +0.223624110, +0.910860300E-2, +0.993391395
729
730count = getUnifRand(4, 10)
731array = getUnifRand(0., 1., count) ! generate random array for illustration.
732array
733+0.726587534, +0.608631730, +0.925797880, +0.521124601E-1, +0.814290404, +0.559526205, +0.361549854E-2, +0.140086949, +0.859499335, +0.434735417
734array = getShuffled(array)
735array
736+0.434735417, +0.608631730, +0.814290404, +0.859499335, +0.726587534, +0.140086949, +0.559526205, +0.521124601E-1, +0.361549854E-2, +0.925797880
737count = getUnifRand(0, size(array))
738count
739+1
740array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
741array
742+0.559526205
743
744count = getUnifRand(4, 10)
745array = getUnifRand(0., 1., count) ! generate random array for illustration.
746array
747+0.318993390, +0.179373920, +0.372578144, +0.333484232, +0.498481095, +0.973862350, +0.414019942
748array = getShuffled(array)
749array
750+0.973862350, +0.318993390, +0.372578144, +0.498481095, +0.414019942, +0.333484232, +0.179373920
751count = getUnifRand(0, size(array))
752count
753+5
754array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
755array
756+0.498481095, +0.372578144, +0.179373920, +0.318993390, +0.333484232
757
758count = getUnifRand(4, 10)
759array = getUnifRand(0., 1., count) ! generate random array for illustration.
760array
761+0.111782074, +0.469655633, +0.724516690, +0.846270025, +0.499872983, +0.270024836, +0.927748084E-1
762array = getShuffled(array)
763array
764+0.927748084E-1, +0.846270025, +0.469655633, +0.499872983, +0.270024836, +0.724516690, +0.111782074
765count = getUnifRand(0, size(array))
766count
767+3
768array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
769array
770+0.111782074, +0.270024836, +0.927748084E-1
771
772count = getUnifRand(4, 10)
773array = getUnifRand(0., 1., count) ! generate random array for illustration.
774array
775+0.199516416, +0.987275541, +0.838656247, +0.192064941, +0.588275731
776array = getShuffled(array)
777array
778+0.588275731, +0.838656247, +0.987275541, +0.192064941, +0.199516416
779count = getUnifRand(0, size(array))
780count
781+5
782array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
783array
784+0.192064941, +0.987275541, +0.588275731, +0.838656247, +0.199516416
785
786count = getUnifRand(4, 10)
787array = getUnifRand(0., 1., count) ! generate random array for illustration.
788array
789+0.934829295, +0.654527485, +0.876336396, +0.434725523, +0.516226888, +0.392868221, +0.448542535, +0.788576603E-1
790array = getShuffled(array)
791array
792+0.788576603E-1, +0.434725523, +0.392868221, +0.516226888, +0.876336396, +0.934829295, +0.654527485, +0.448542535
793count = getUnifRand(0, size(array))
794count
795+7
796array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
797array
798+0.788576603E-1, +0.392868221, +0.516226888, +0.876336396, +0.434725523, +0.654527485, +0.448542535
799
800count = getUnifRand(4, 10)
801array = getUnifRand(0., 1., count) ! generate random array for illustration.
802array
803+0.904647887, +0.122345090E-1, +0.953199506, +0.914491594, +0.605823338, +0.690645933, +0.224837422, +0.301459968
804array = getShuffled(array)
805array
806+0.122345090E-1, +0.224837422, +0.301459968, +0.690645933, +0.605823338, +0.953199506, +0.914491594, +0.904647887
807count = getUnifRand(0, size(array))
808count
809+6
810array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
811array
812+0.301459968, +0.953199506, +0.122345090E-1, +0.605823338, +0.224837422, +0.690645933
813
814count = getUnifRand(4, 10)
815array = getUnifRand(0., 1., count) ! generate random array for illustration.
816array
817+0.604639888, +0.757256031, +0.954138339, +0.988435566, +0.763476670, +0.796259701, +0.146933794E-1, +0.963363171
818array = getShuffled(array)
819array
820+0.954138339, +0.963363171, +0.757256031, +0.604639888, +0.988435566, +0.796259701, +0.146933794E-1, +0.763476670
821count = getUnifRand(0, size(array))
822count
823+5
824array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
825array
826+0.604639888, +0.757256031, +0.988435566, +0.954138339, +0.963363171
827
828count = getUnifRand(4, 10)
829array = getUnifRand(0., 1., count) ! generate random array for illustration.
830array
831+0.193989217, +0.879534483E-1, +0.325640619, +0.755990148, +0.227874219, +0.421916068, +0.799202800
832array = getShuffled(array)
833array
834+0.879534483E-1, +0.227874219, +0.325640619, +0.421916068, +0.193989217, +0.799202800, +0.755990148
835count = getUnifRand(0, size(array))
836count
837+6
838array = getShuffled(array, count) ! draw randomly only `count` elements without replacement.
839array
840+0.879534483E-1, +0.421916068, +0.799202800, +0.325640619, +0.227874219, +0.755990148
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: