Return a random vector from the \(\ndim\)-dimensional MultiVariate Uniform Parallelepiped (MVUP) Distribution.
More...
Return a random vector from the \(\ndim\)-dimensional MultiVariate Uniform Parallelepiped (MVUP) Distribution.
See the documentation of pm_distUnifPar for details of the definition of the PDF.
- Parameters
-
[in,out] | rand | : The input/output vector of shape (1:ndim) of,
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128).
On input, it must contain a vector of randomly uniformly-distributed numbers in the range \([0, 1)\).
On output, it will contain a random vector from the support of the target distribution.
|
[in] | lb | : The input scalar or contiguous vector of the same type and kind as the output argument rand .
-
If
ub is a scalar, then lb must be a scalar representing the lower bound of the ndim -dimensional hyper-cube support of the distribution.
-
If
ub is a vector, then lb must be a vector representing the lower bound of the ndim -dimensional hyper-rectangle support of the distribution.
-
If
ub is a matrix, then lb must be a vector representing the origin of the coordinate system with respect to which the ndim -dimensional hyper-parallelepiped support of the distribution is determined.
(optional. default = 0 ) |
[in] | ub | : The input scalar or contiguous vector/matrix of the same type and kind as the output argument rand .
-
If
ub is a scalar, it must contain the upper bound of the ndim -dimensional hyper-cube support of the distribution.
In such a case, the input optional argument ndim must be specified.
-
If
ub is a vector of shape (1:ndim) , it must contain the upper bounds of the ndim -dimensional hyper-rectangle support of the distribution along each dimension.
-
If
ub is a square matrix of shape (1:ndim, 1:ndim) , it must contain the representative matrix of the ndim -dimensional hyper-parallelepiped support of the distribution.
|
Possible calling interfaces ⛓
call random_number(rand(1:ndim))
call random_number(rand(1:ndim))
call random_number(rand(1:ndim))
call random_number(rand(1:ndim))
call random_number(rand(1:ndim))
call random_number(rand(1:ndim))
!
Return a random vector from the -dimensional MultiVariate Uniform Parallelepiped (MVUP) Distribution.
This module contains classes and procedures for setting up and computing the properties of the MultiV...
- Warning
- The condition
all(0. <= rand .and. rand < 1.)
must hold for the corresponding input arguments.
The condition all(size(rand) == size(lb(:)))
must hold for the corresponding input arguments.
The condition all(size(rand) == shape(ub))
must hold for the corresponding input arguments.
The condition all(lb /= ub(:))
must hold for the corresponding input arguments.
Although there is theoretically no limit on the possible values of lb
and ub
with respect to each other, the condition all(lb(:) < ub(:))
is expected (but not checked) to hold for the corresponding input arguments.
The input representative matrix of the parallelepiped support of the distribution ub(:,:)
must be non-singular.
In other words, the columns of the matrix must span the \(\mathbb{R}^{\ndim}\) space.
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.
Example usage ⛓
11 type(display_type) :: disp
15 call disp%show(
"call random_number(rand(1:2))")
16 call random_number(rand(
1:
2))
17 call disp%show(
"call setUnifParRand(rand(1:2), ub = 1.)")
24 call disp%show(
"call random_number(rand(1:2))")
25 call random_number(rand(
1:
2))
26 call disp%show(
"call setUnifParRand(rand(1:2), lb = -100., ub = 1.)")
33 call disp%show(
"call random_number(rand(1:5))")
34 call random_number(rand(
1:
5))
35 call disp%show(
"call setUnifParRand(rand(1:5), ub = [1., 2., 3., 4., 5.]) ! random vector of dimension 5.")
42 call disp%show(
"call random_number(rand(1:5))")
43 call random_number(rand(
1:
5))
44 call disp%show(
"call setUnifParRand(rand(1:5), lb = -[1., 2., 3., 4., 5.], ub = [1., 2., 3., 4., 5.]) ! random vector of dimension 5.")
45 call setUnifParRand(rand(
1:
5), lb
= -[
1.,
2.,
3.,
4.,
5.], ub
= [
1.,
2.,
3.,
4.,
5.])
51 call disp%show(
"call random_number(rand(1:2))")
52 call random_number(rand(
1:
2))
53 call disp%show(
"call setUnifParRand(rand(1:2), ub = reshape([1., 1., -1., -1.], shape = [2, 2]))")
54 call setUnifParRand(rand(
1:
2), ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
60 call disp%show(
"call random_number(rand(1:2))")
61 call random_number(rand(
1:
2))
62 call disp%show(
"call setUnifParRand(rand(1:2), lb = [10., 10.], ub = reshape([1., 1., -1., -1.], shape = [2, 2]))")
63 call setUnifParRand(rand(
1:
2), lb
= [
10.,
10.], ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
75 integer(IK) :: fileUnit, i
76 open(newunit
= fileUnit, file
= "setUnifParRand.RK.txt")
78 call random_number(rand)
80 call setUnifParRand(rand(:,
2), ub
= reshape([
1.,
1.,
-1.,
+1.], shape
= [
2,
2]))
81 call setUnifParRand(rand(:,
3), lb
= [
2.0,
-2.], ub
= reshape([
1.,
1.,
+2.,
-2.], shape
= [
2,
2]))
82 call setUnifParRand(rand(:,
4), lb
= [
1.5,
-.
5], ub
= reshape([
2.,
1.,
1.,
2.], shape
= [
2,
2]))
83 write(fileUnit,
"(*(g0,:,','))") rand
Return the linSpace output argument with size(linSpace) elements of evenly-spaced values over the int...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains procedures and generic interfaces for generating arrays with linear or logarithm...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
2call random_number(rand(
1:
2))
5+0.446436286,
+0.106434882
8call random_number(rand(
1:
2))
11-86.5660019,
-58.6573372
14call random_number(rand(
1:
5))
17+0.441022336,
+0.249059796,
+1.95939755,
+3.76885104,
+1.25133538
20call random_number(rand(
1:
5))
21call setUnifParRand(rand(
1:
5), lb
= -[
1.,
2.,
3.,
4.,
5.], ub
= [
1.,
2.,
3.,
4.,
5.])
23-0.207175374,
-0.693487883,
+0.384066582,
-1.06522036,
+2.45016193
26call random_number(rand(
1:
2))
27call setUnifParRand(rand(
1:
2), ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
29-0.752362728,
-0.752362728
32call random_number(rand(
1:
2))
33call setUnifParRand(rand(
1:
2), lb
= [
10.,
10.], ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
35+9.10447311,
+9.10447311
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
14 pattern =
"*." + kind +
".txt"
15 fileList = glob.glob(pattern)
19 df = pd.read_csv(file, delimiter =
",", header =
None)
27 fig = plt.figure(figsize = (8, 6))
29 plt.rcParams.update({
'font.size': fontsize - 2})
45 for i
in range(0, len(df.values[0,:]), 2):
46 ax.scatter ( df.values[:,i]
55 ax.set_aspect(
"equal")
56 ax.set_xlabel(
"X", fontsize = 17)
57 ax.set_ylabel(
"Y", fontsize = 17)
58 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
62 plt.savefig(file.replace(
".txt",
".png"))
Visualization of the example output ⛓
- Test:
- test_pm_distUnifPar
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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- Author:
- Amir Shahmoradi, April 23, 2017, 12:36 AM, Institute for Computational Engineering and Sciences (ICES), University of Texas at Austin
Definition at line 920 of file pm_distUnifPar.F90.