Generate and return a random vector from the \(\ndim\)-dimensional MultiVariate Uniform Parallelepiped (MVUP) Distribution.
More...
Generate and 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] | 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 represents 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 represents 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 contains the representative matrix of the ndim -dimensional hyper-parallelepiped support of the distribution.
|
[in] | ndim | : The input positive scalar of type integer of default kind IK, containing the number of dimensions of the domain of the distribution.
(optional. It must be present if and only if the input lb and ub are scalar.) |
- Returns
rand
: The output vector of shape (1:ndim)
of,
-
type
real
of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing a random vector from the support of the distribution.
Possible calling interfaces ⛓
!
Generate and return a random vector from the -dimensional MultiVariate Uniform Parallelepiped (MVUP) ...
This module contains classes and procedures for setting up and computing the properties of the MultiV...
- Warning
- The condition
0 < ndim
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.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
Example usage ⛓
11 type(display_type) :: disp
15 call disp%show(
"rand(1:2) = getUnifParRand(ub = 1., ndim = 2)")
22 call disp%show(
"rand(1:2) = getUnifParRand(lb = -100., ub = 1., ndim = 2)")
29 call disp%show(
"rand(1:5) = getUnifParRand(ub = [1., 2., 3., 4., 5.]) ! random vector of dimension 5.")
36 call disp%show(
"rand(1:5) = getUnifParRand(lb = -[1., 2., 3., 4., 5.], ub = [1., 2., 3., 4., 5.]) ! random vector of dimension 5.")
37 rand(
1:
5)
= getUnifParRand(lb
= -[
1.,
2.,
3.,
4.,
5.], ub
= [
1.,
2.,
3.,
4.,
5.])
43 call disp%show(
"rand(1:2) = getUnifParRand(ub = reshape([1., 1., -1., -1.], shape = [2, 2]))")
44 rand(
1:
2)
= getUnifParRand(ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
50 call disp%show(
"rand(1:2) = getUnifParRand(lb = [10., 10.], ub = reshape([1., 1., -1., -1.], shape = [2, 2]))")
51 rand(
1:
2)
= getUnifParRand(lb
= [
10.,
10.], ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
63 integer(IK) :: fileUnit, i
64 open(newunit
= fileUnit, file
= "getUnifParRand.RK.txt")
67 rand(:,
2)
= getUnifParRand(ub
= reshape([
1.,
1.,
-1.,
+1.], shape
= [
2,
2]))
68 rand(:,
3)
= getUnifParRand(lb
= [
2.0,
-2.], ub
= reshape([
1.,
1.,
+2.,
-2.], shape
= [
2,
2]))
69 rand(:,
4)
= getUnifParRand(lb
= [
1.5,
-.
5], ub
= reshape([
2.,
1.,
1.,
2.], shape
= [
2,
2]))
70 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 ⛓
4+0.840460420,
+0.920725644
9-71.4284286,
-19.9418945
14+0.505086064,
+0.528709054,
+2.81106710,
+2.25829482,
+3.17950296
17rand(
1:
5)
= getUnifParRand(lb
= -[
1.,
2.,
3.,
4.,
5.], ub
= [
1.,
2.,
3.,
4.,
5.])
19+0.669151545E-1,
+1.31154490,
+2.16635370,
+1.24457455,
+4.58814335
22rand(
1:
2)
= getUnifParRand(ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
24+0.943078637,
+0.943078637
27rand(
1:
2)
= getUnifParRand(lb
= [
10.,
10.], ub
= reshape([
1.,
1.,
-1.,
-1.], shape
= [
2,
2]))
29+10.7303648,
+10.7303648
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 470 of file pm_distUnifPar.F90.