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

Return the Cumulative Distribution Function (CDF) of a univariate Standard Uniform distribution or a Uniform distribution with the specified support via lower and upper input arguments at the specified input values. More...

Detailed Description

Return the Cumulative Distribution Function (CDF) of a univariate Standard Uniform distribution or a Uniform distribution with the specified support via lower and upper input arguments at the specified input values.

Parameters
[out]cdf: The output scalar or contiguous array of rank 1 of either
  1. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128) (if the input value x is of type complex) or,
  2. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128) (if the input value x is of type integer or real),
containing the CDF of the specified discrete or continuous Uniform distribution.
[in]x: The input scalar or contiguous array of the same shape as cdf, containing the values at which the CDF must be computed.
If x is of type integer, the CDF of the discrete Uniform distribution with support [lower, upper] will be returned.
If x is of type integer, the output argument CDF must be of type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128).
If x is of type real, the output argument CDF must have the same type, kind, and rank as x, and will contain the CDF of the continuous Uniform distribution with support [lower, upper).
If x is of type complex, the output argument CDF must have the same type, kind, and rank as x.
If x is of type complex, the two real and imaginary components of CDF will correspond to two independent distributions.
[in]lower: The input scalar of the same type and kind as x, representing the lower bound of the Uniform distribution.
(optional, default = 0. If present, then upper must also be present.)
[in]upper: The input scalar of the same type and kind as x, representing the upper bound of the Uniform distribution.
(optional, default = 1. If present, then lower must also be present.)


Possible calling interfaces

call setUnifCDF(cdf, x)
call setUnifCDF(cdf, x, lower, upper)
Return the Cumulative Distribution Function (CDF) of a univariate Standard Uniform distribution or a ...
This module contains classes and procedures for computing various statistical quantities related to t...
Warning
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.
Remarks
The procedures under discussion are elemental.
See also
getUnifCDF


Example usage

1program example
2
3 use pm_kind, only: SK ! All kinds are supported.
4 use pm_kind, only: IK ! All kinds are supported.
5 use pm_kind, only: CK ! All kinds are supported.
6 use pm_kind, only: RK ! All kinds are supported.
7 use pm_io, only: display_type
9 use pm_distUnif, only: setUnifCDF
10 use pm_arrayRange, only: getRange
11
12 implicit none
13
14 integer(IK) , parameter :: NP = 1000_IK
15
16 ! 1-dimensional array of x values.
17
18 integer(IK) , allocatable :: Point_IK(:)
19 real(RK) , allocatable :: Point_RK(:), CDF_RK(:), CDF_IK(:)
20 complex(CK) , allocatable :: Point_CK(:), CDF_CK(:)
21
22 integer(IK) :: range_IK, lower_IK = -3_IK , upper_IK = +4_IK
23 real(RK) :: range_RK, lower_RK = -4._RK , upper_RK = +4._RK
24 complex(CK) :: range_CK, lower_CK = (-4._CK,-1._CK) , upper_CK = (+4._CK,+3._CK)
25
26 type(display_type) :: disp
27 disp = display_type(file = "main.out.F90")
28
29 range_IK = upper_IK - lower_IK
30 range_RK = upper_RK - lower_RK
31 range_CK = upper_CK - lower_CK
32
33 Point_IK = getRange(lower_IK - range_IK/2, upper_IK + range_IK/2)
34 Point_RK = getLinSpace(lower_RK - range_RK/2, upper_RK + range_RK/2, count = NP)
35 Point_CK = getLinSpace(lower_CK - range_CK/2, upper_CK + range_CK/2, count = NP)
36 allocate(CDF_IK(size(Point_IK)))
37 allocate(CDF_RK(size(Point_RK)))
38 allocate(CDF_CK(size(Point_CK)))
39
40 call disp%skip()
41 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
42 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
43 call disp%show("! Compute the Cumulative Distribution Function (CDF) of the Uniform distribution at the specified values.")
44 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
45 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
46 call disp%skip()
47
48 call disp%skip()
49 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
50 call disp%show("! Compute the discrete Uniform CDF at an input scalar integer value.")
51 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
52 call disp%skip()
53
54 call disp%skip()
55 call disp%show("call setUnifCDF(CDF_IK(1), x = 0_IK)")
56 call setUnifCDF(CDF_IK(1), x = 0_IK)
57 call disp%show("CDF_IK(1)")
58 call disp%show( CDF_IK(1) )
59 call disp%skip()
60
61 call disp%skip()
62 call disp%show("lower_IK")
63 call disp%show( lower_IK )
64 call disp%show("upper_IK")
65 call disp%show( upper_IK )
66 call disp%show("call setUnifCDF(CDF_IK(1), x = 0_IK, lower = lower_IK, upper = upper_IK)")
67 call setUnifCDF(CDF_IK(1), x = 0_IK, lower = lower_IK, upper = upper_IK)
68 call disp%show("CDF_IK(1)")
69 call disp%show( CDF_IK(1) )
70 call disp%skip()
71
72 call disp%skip()
73 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
74 call disp%show("! Compute the continuous Uniform CDF at an input scalar real value.")
75 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
76 call disp%skip()
77
78 call disp%skip()
79 call disp%show("call setUnifCDF(CDF_RK(1), x = 0._RK)")
80 call setUnifCDF(CDF_RK(1), x = 0._RK)
81 call disp%show("CDF_RK(1)")
82 call disp%show( CDF_RK(1) )
83 call disp%skip()
84
85 call disp%skip()
86 call disp%show("lower_RK")
87 call disp%show( lower_RK )
88 call disp%show("upper_RK")
89 call disp%show( upper_RK )
90 call disp%show("call setUnifCDF(CDF_RK(1), x = 0._RK, lower = lower_RK, upper = upper_RK)")
91 call setUnifCDF(CDF_RK(1), x = 0._RK, lower = lower_RK, upper = upper_RK)
92 call disp%show("CDF_RK(1)")
93 call disp%show( CDF_RK(1) )
94 call disp%skip()
95
96 call disp%skip()
97 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
98 call disp%show("! Compute the continuous Uniform CDF at an input scalar complex value.")
99 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
100 call disp%skip()
101
102 call disp%skip()
103 call disp%show("call setUnifCDF(CDF_CK(1), x = (0._CK,0._CK))")
104 call setUnifCDF(CDF_CK(1), x = (0._CK,0._CK))
105 call disp%show("CDF_CK(1)")
106 call disp%show( CDF_CK(1) )
107 call disp%skip()
108
109 call disp%skip()
110 call disp%show("lower_CK")
111 call disp%show( lower_CK )
112 call disp%show("upper_CK")
113 call disp%show( upper_CK )
114 call disp%show("call setUnifCDF(CDF_CK(1), x = (0._CK,0._CK), lower = lower_CK, upper = upper_CK)")
115 call setUnifCDF(CDF_CK(1), x = (0._CK,0._CK), lower = lower_CK, upper = upper_CK)
116 call disp%show("CDF_CK(1)")
117 call disp%show( CDF_CK(1) )
118 call disp%skip()
119
120 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 ! Output an example array for visualization.
122 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123
124 call setUnifCDF(CDF_IK, Point_IK, lower_IK, upper_IK)
125 call setUnifCDF(CDF_RK, Point_RK, lower_RK, upper_RK)
126 call setUnifCDF(CDF_CK, Point_CK, lower_CK, upper_CK)
127
128 block
129
130 integer :: fileUnit, i
131
132 open(newunit = fileUnit, file = "main.unif.cdf.IK.txt")
133 write(fileUnit,"(2(g0,:,' '))") (Point_IK(i), CDF_IK(i), i = 1, size(Point_IK))
134 close(fileUnit)
135
136 open(newunit = fileUnit, file = "main.unif.cdf.RK.txt")
137 write(fileUnit,"(2(g0,:,' '))") (Point_RK(i), CDF_RK(i), i = 1, size(Point_RK))
138 close(fileUnit)
139
140 open(newunit = fileUnit, file = "main.unif.cdf.CK.txt")
141 write(fileUnit,"(4(g0,:,' '))") (Point_CK(i), CDF_CK(i), i = 1, size(Point_CK))
142 close(fileUnit)
143
144 end block
145
146end program example
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
Generate count evenly spaced points over the interval [x1, x2] if x1 < x2, or [x2,...
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 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...
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 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
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4! Compute the Cumulative Distribution Function (CDF) of the Uniform distribution at the specified values.
5!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
8
9!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10! Compute the discrete Uniform CDF at an input scalar integer value.
11!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
13
14call setUnifCDF(CDF_IK(1), x = 0_IK)
15CDF_IK(1)
16+0.50000000000000000
17
18
19lower_IK
20-3
21upper_IK
22+4
23call setUnifCDF(CDF_IK(1), x = 0_IK, lower = lower_IK, upper = upper_IK)
24CDF_IK(1)
25+0.50000000000000000
26
27
28!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29! Compute the continuous Uniform CDF at an input scalar real value.
30!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
32
33call setUnifCDF(CDF_RK(1), x = 0._RK)
34CDF_RK(1)
35+0.0000000000000000
36
37
38lower_RK
39-4.0000000000000000
40upper_RK
41+4.0000000000000000
42call setUnifCDF(CDF_RK(1), x = 0._RK, lower = lower_RK, upper = upper_RK)
43CDF_RK(1)
44+0.50000000000000000
45
46
47!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48! Compute the continuous Uniform CDF at an input scalar complex value.
49!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50
51
52call setUnifCDF(CDF_CK(1), x = (0._CK,0._CK))
53CDF_CK(1)
54(+0.0000000000000000, +1.0000000000000000)
55
56
57lower_CK
58(-4.0000000000000000, -1.0000000000000000)
59upper_CK
60(+4.0000000000000000, +3.0000000000000000)
61call setUnifCDF(CDF_CK(1), x = (0._CK,0._CK), lower = lower_CK, upper = upper_CK)
62CDF_CK(1)
63(+0.50000000000000000, +0.25000000000000000)
64
65

Postprocessing of the example output
1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4import pandas as pd
5import numpy as np
6
7fontsize = 17
8
9marker ={ "IK" : "."
10 , "RK" : "-"
11 , "CK" : "-"
12 }
13ylab = { "IK" : "Discrete Integer Uniform CDF"
14 , "RK" : "Continuous Real Uniform CDF"
15 , "CK" : "Continuous Complex Uniform CDF"
16 }
17
18for kind in ["IK", "RK", "CK"]:
19
20 df = pd.read_csv("main.unif.cdf."+kind+".txt", delimiter = " ")
21
22 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
23 ax = plt.subplot()
24
25 if kind == "CK":
26 plt.plot( df.values[:, 0]
27 , df.values[:,2]
28 , marker[kind]
29 , color = "r"
30 )
31 plt.plot( df.values[:, 1]
32 , df.values[:,3]
33 , marker[kind]
34 , color = "blue"
35 )
36 ax.legend ( ["real", "imaginary"]
37 , fontsize = fontsize
38 )
39 else:
40 plt.plot( df.values[:, 0]
41 , df.values[:, 1]
42 , marker[kind]
43 , color = "r"
44 )
45
46 ax.set_xlabel("X", fontsize = 17)
47 ax.set_ylabel(ylab[kind], fontsize = 17)
48
49 plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
50 ax.tick_params(axis = "y", which = "minor")
51 ax.tick_params(axis = "x", which = "minor")
52
53 plt.savefig("setUnifCDF."+kind+".png")

Visualization of the example output
Test:
test_pm_distUnif
Todo:
Low Priority: This generic interface can be extended to input arguments with ranks higher than 1.
Todo:
Normal Priority: This generic interface can be extended to input string arguments to make it compatible with setUnifRand.


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, Oct 16, 2009, 11:14 AM, Michigan

Definition at line 835 of file pm_distUnif.F90.


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