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

Generate and return a reweighting of the input weight vector, such that the sequence represented by output reweight is the refined (skipped by the amount skip) version of the sequence represented by the input weight.
More...

Detailed Description

Generate and return a reweighting of the input weight vector, such that the sequence represented by output reweight is the refined (skipped by the amount skip) version of the sequence represented by the input weight.

The following examples illustrate the specific functioning of this generic interface:

skip: 1
Weight: 5, 0, 1, 3, 1
RefinedWeight: 5, 0, 1, 3, 1
skip: 2
Weight: 5, 0, 1, 3, 1
RefinedWeight: 3, 0, 0, 2, 0
skip: 3
Weight: 5, 0, 1, 3, 1
RefinedWeight: 2, 0, 0, 1, 1
Parameters
[in]weight: The input contiguous array of shape (:) of
  1. type integer of default kind IK,
  2. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
  3. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the weights that are to be reweighted (refined).
Non-positive values are allowed, but ignored by definition and reset to zero in the output reweight.
[in]skip: The input scalar of the same type and kind as the input weight, representing the size of the skip in the sequence whose weight is given as input.
If the input weight is of type integer of default kind IK, then skip can be also of type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128).
Returns
reweight : The output object of the same type, kind, rank, shape, and size as the input weight containing the refined weights by the input amount skip.
Any element of the input weight that does not contribute to the output refined weight is set to 0 on output.


Possible calling interfaces

reweight(1 : size(weight)) = getReweight(weight, skip)
Generate and return a reweighting of the input weight vector, such that the sequence represented by o...
This module contains the types, classes, and procedures relevant to weights of random samples.
Warning
The condition 0 < skip must hold.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
Developer Remark:
The term reweight here stands for refined weight.
See also
getReweight
setReweight
getRefined
setRefined
getCompact
setCompact
getVerbose


Example usage

1program example
2
3 use pm_kind, only: SK, IK, LK
5 use pm_distUnif, only: getUnifRand
6 use pm_io, only: display_type
7
8 implicit none
9
10 type(display_type) :: disp
11 integer(IK) :: lenwei, itry, ntry = 10
12 disp = display_type(file = "main.out.F90")
13
14 block
15 use pm_kind, only: IKG => IK ! all processor kinds are supported.
16 integer(IKG), allocatable :: weight(:)
17 integer(IKG) :: skip
18 do itry = 1, ntry
19 call disp%show("lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)")
20 lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
21 call disp%show("lenwei")
22 call disp%show( lenwei )
23 call disp%show("skip")
24 call disp%show( skip )
25 call disp%show("weight = getUnifRand(-1, 9, lenwei)")
26 weight = getUnifRand(-1, 9, lenwei)
27 call disp%show("weight")
28 call disp%show( weight )
29 call disp%show("weight = getReweight(weight, skip)")
30 weight = getReweight(weight, skip)
31 call disp%show("weight")
32 call disp%show( weight )
33 call disp%skip()
34 end do
35 end block
36
37 block
38 use pm_kind, only: RKG => RKS ! all processor kinds are supported.
39 real(RKG), allocatable :: weight(:)
40 real(RKG) :: skip
41 do itry = 1, ntry
42 call disp%show("lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)")
43 lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
44 call disp%show("lenwei")
45 call disp%show( lenwei )
46 call disp%show("skip")
47 call disp%show( skip )
48 call disp%show("weight = getUnifRand(-1._RKG, 9._RKG, lenwei)")
49 weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
50 call disp%show("weight")
51 call disp%show( weight )
52 call disp%show("weight = getReweight(weight, skip)")
53 weight = getReweight(weight, skip)
54 call disp%show("weight")
55 call disp%show( weight )
56 call disp%skip()
57 end do
58 end block
59
60end program example
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 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 LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
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
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Definition: pm_kind.F90:567
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
1lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
2lenwei
3+4
5+1
6weight = getUnifRand(-1, 9, lenwei)
7weight
8+8, +2, +5, +1
9weight = getReweight(weight, skip)
10weight
11+8, +2, +5, +1
12
13lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
14lenwei
15+0
16skip
17+2
18weight = getUnifRand(-1, 9, lenwei)
19weight
20
21weight = getReweight(weight, skip)
22weight
23
24
25lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
26lenwei
27+3
28skip
29+2
30weight = getUnifRand(-1, 9, lenwei)
31weight
32+1, -1, +2
33weight = getReweight(weight, skip)
34weight
35+0, +0, +1
36
37lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
38lenwei
39+9
40skip
41+2
42weight = getUnifRand(-1, 9, lenwei)
43weight
44+9, +0, +2, +1, +2, +0, +9, +2, +1
45weight = getReweight(weight, skip)
46weight
47+4, +0, +1, +1, +1, +0, +4, +1, +1
48
49lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
50lenwei
51+5
52skip
53+2
54weight = getUnifRand(-1, 9, lenwei)
55weight
56+9, +8, +1, +9, +5
57weight = getReweight(weight, skip)
58weight
59+4, +4, +1, +4, +3
60
61lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
62lenwei
63+5
64skip
65+3
66weight = getUnifRand(-1, 9, lenwei)
67weight
68+0, +9, +2, +8, +3
69weight = getReweight(weight, skip)
70weight
71+0, +3, +0, +3, +1
72
73lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
74lenwei
75+2
76skip
77+1
78weight = getUnifRand(-1, 9, lenwei)
79weight
80+0, +7
81weight = getReweight(weight, skip)
82weight
83+0, +7
84
85lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
86lenwei
87+9
88skip
89+1
90weight = getUnifRand(-1, 9, lenwei)
91weight
92+1, +5, +7, +3, +4, -1, +3, +8, +3
93weight = getReweight(weight, skip)
94weight
95+1, +5, +7, +3, +4, +0, +3, +8, +3
96
97lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
98lenwei
99+1
100skip
101+1
102weight = getUnifRand(-1, 9, lenwei)
103weight
104+5
105weight = getReweight(weight, skip)
106weight
107+5
108
109lenwei = getUnifRand(0, 9); skip = getUnifRand(1, 4)
110lenwei
111+9
112skip
113+1
114weight = getUnifRand(-1, 9, lenwei)
115weight
116-1, +2, +5, +2, +3, +7, +0, +7, +5
117weight = getReweight(weight, skip)
118weight
119+0, +2, +5, +2, +3, +7, +0, +7, +5
120
121lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
122lenwei
123+2
124skip
125+1.86731720
126weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
127weight
128+5.81369638, +1.72295105
129weight = getReweight(weight, skip)
130weight
131+3.00000000, +1.00000000
132
133lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
134lenwei
135+0
136skip
137+0.497249305
138weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
139weight
140
141weight = getReweight(weight, skip)
142weight
143
144
145lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
146lenwei
147+8
148skip
149+2.83334208
150weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
151weight
152+2.41715145, +4.46863365, +1.93150055, +5.64112139, +0.590288877, -0.660055041, +0.754667759, +3.51605272
153weight = getReweight(weight, skip)
154weight
155+0.00000000, +2.00000000, +1.00000000, +2.00000000, +0.00000000, +0.00000000, +0.00000000, +1.00000000
156
157lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
158lenwei
159+5
160skip
161+3.41111088
162weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
163weight
164+8.08675480, +1.76160288, +7.28904963, +3.64977264, +7.72790432
165weight = getReweight(weight, skip)
166weight
167+2.00000000, +0.00000000, +3.00000000, +1.00000000, +2.00000000
168
169lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
170lenwei
171+3
172skip
173+2.43756032
174weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
175weight
176+4.72088099, +2.45876408, +5.02810383
177weight = getReweight(weight, skip)
178weight
179+1.00000000, +1.00000000, +3.00000000
180
181lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
182lenwei
183+6
184skip
185+1.38791656
186weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
187weight
188+1.33819246, +5.70097971, +7.74290943, +8.49916553, +8.85902119, +4.06304884
189weight = getReweight(weight, skip)
190weight
191+0.00000000, +5.00000000, +5.00000000, +6.00000000, +7.00000000, +3.00000000
192
193lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
194lenwei
195+0
196skip
197+3.97900939
198weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
199weight
200
201weight = getReweight(weight, skip)
202weight
203
204
205lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
206lenwei
207+7
208skip
209+3.96889377
210weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
211weight
212-0.223276615E-1, +6.48702621, +7.64338398, +4.12399721, +5.93803740, +7.94937611, +5.14441299
213weight = getReweight(weight, skip)
214weight
215+0.00000000, +1.00000000, +2.00000000, +1.00000000, +2.00000000, +2.00000000, +1.00000000
216
217lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
218lenwei
219+4
220skip
221+2.25702167
222weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
223weight
224+8.70080280, -0.257233381E-1, +7.52042341, +0.284880638
225weight = getReweight(weight, skip)
226weight
227+3.00000000, +0.00000000, +4.00000000, +0.00000000
228
229lenwei = getUnifRand(0, 9); skip = getUnifRand(.1_RKG, 4._RKG)
230lenwei
231+9
232skip
233+1.69658232
234weight = getUnifRand(-1._RKG, 9._RKG, lenwei)
235weight
236+7.94116592, +6.52444649, +7.69537926, +1.07927346, +1.11038113, +7.96268940, +6.06229973, -0.212419391, +8.38480282
237weight = getReweight(weight, skip)
238weight
239+4.00000000, +4.00000000, +5.00000000, +0.00000000, +1.00000000, +5.00000000, +3.00000000, +0.00000000, +5.00000000
240
241
Test:
test_pm_sampleWeight


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, Saturday 1:48 AM, August 20, 2016, Institute for Computational Engineering and Sciences, UT Austin, TX

Definition at line 374 of file pm_sampleWeight.F90.


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