Generate and return a scalar or array of arbitrary rank of random values from the univariate Normal distribution with the specified input mean
and optionally, with the specified input standard deviation std
of the Normal distribution.
More...
Generate and return a scalar or array of arbitrary rank of random values from the univariate Normal distribution with the specified input mean
and optionally, with the specified input standard deviation std
of the Normal distribution.
The procedures of this generic interface are merely convenient wrappers around the procedures of setNormRand.
 Parameters

[in]  mean  : The input scalar or array of the same shape as other arraylike arguments, of the same type and kind as rand , representing the mean of the Normal distribution.

[in]  std  : The input scalar or array of the same shape as other arraylike arguments, of the same type and kind as rand , representing the standard deviation of the Normal distribution.
(optional, default = 1. , can be present only if mean is also present.) 
 Returns
rand
: The output scalar or array of arbitrary rank, of

type
real
of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the Normaldistributed random output value.
Possible calling interfaces ⛓
Generate and return a scalar or array of arbitrary rank of random values from the univariate Normal d...
This module contains classes and procedures for computing various statistical quantities related to t...
 Warning
 The condition
0. < std
must hold for the corresponding input arguments.
All warnings and notes for setNormRand also apply to the procedures of this generic interface.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
 See also
 getNormRand
setNormRand
setNormRandBox
getNormLogPDF
getNormCDF
Example usage ⛓
12 integer(IK),
parameter :: NP
= 1000_IK
13 real(RK), dimension(NP) :: mean, std, rand
15 type(display_type) :: disp
19 call setLogSpace(std, logx1
= log(
0.1_RK), logx2
= log(
10._RK))
22 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
23 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
24 call disp%show(
"! Generate random numbers from the Normal distribution.")
25 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
26 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
30 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
31 call disp%show(
"! Normal random number with a particular mean and default unity standard deviation.")
32 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
38 call disp%show(
"rand(1:3) = getNormRand(mean(1))")
45 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
46 call disp%show(
"! Normal random number with given mean and standard deviation.")
47 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
55 call disp%show(
"rand(1:2) = getNormRand(mean(1), std(1))")
62 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
63 call disp%show(
"! Normal random numbers with a fixed set of mean and standard deviation.")
64 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
72 call disp%show(
"rand(1:NP:NP/3) = getNormRand(mean(1), std(1))")
79 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
80 call disp%show(
"! Normal random number with a range of means and standard deviations.")
81 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
89 call disp%show(
"rand(1:NP:NP/3) = getNormRand(mean(1:NP:NP/3), std(1:NP:NP/3))")
90 rand(
1:NP:NP
/3)
= getNormRand(mean(
1:NP:NP
/3), std(
1:NP:NP
/3))
100 integer(IK) :: fileUnit, i
101 integer(IK),
parameter :: NP
= 5000_IK
102 open(newunit
= fileUnit, file
= "getNormRand.RK.txt")
103 write(fileUnit,
"(3(g0,:,' '))") (
getNormRand(
+2._RK, std
= 3.0_RK)
&
Return the linSpace output argument with size(linSpace) elements of evenlyspaced values over the int...
Return the logSpace output argument with size(logSpace) elements of logarithmicallyevenlyspaced val...
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 typeparameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in CFortran Interoperati...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in CFortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in CFortran Intero...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort fpp standardsemantics 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 /standardsemantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran cpp ffreelinelengthnone O3 Wl,rpath,../../../lib I../../../inc main.F90 ../../../lib/libparamonte* o main.exe
Example output ⛓
185.5325347281124042,
5.5325347281124042,
5.5325347281124042
415.0000000000000000,
1.6666666666666665,
+1.6666666666666670,
+5.0000000000000000
43+0.10000000000000003,
+0.46415888336127803,
+2.1544346900318851,
+10.000000000000004
465.0513701982096961,
5.0513701982096961,
5.0513701982096961,
5.0513701982096961
555.0000000000000000,
1.6666666666666665,
+1.6666666666666670,
+5.0000000000000000
57+0.10000000000000003,
+0.46415888336127803,
+2.1544346900318851,
+10.000000000000004
58rand(
1:NP:NP
/3)
= getNormRand(mean(
1:NP:NP
/3), std(
1:NP:NP
/3))
605.0632563221458851,
0.38165999762397851,
+3.0087612145811047,
+5.4982106063748439
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
16xlab = {
"CK" :
"Normal Random Number ( real/imaginary components )"
17 ,
"IK" :
"Normal Random Number ( integervalued )"
18 ,
"RK" :
"Normal Random Number ( realvalued )"
20legends = [
r"$\mu = 5.,~\sigma = 1.0$"
21 ,
r"$\mu = 0.0,~\sigma = 1.0$"
22 ,
r"$\mu = 2.0,~\sigma = 3.0$"
25for kind
in [
"IK",
"CK",
"RK"]:
27 pattern =
"*." + kind +
".txt"
28 fileList = glob.glob(pattern)
29 if len(fileList) == 1:
31 df = pd.read_csv(fileList[0], delimiter =
" ", header =
None)
33 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
37 plt.hist( df.values[:,0:3]
38 , histtype =
"stepfilled"
43 plt.hist( df.values[:,0:3]
44 , histtype =
"stepfilled"
51 plt.xticks(fontsize = fontsize  2)
52 plt.yticks(fontsize = fontsize  2)
53 ax.set_xlabel(xlab[kind], fontsize = 17)
54 ax.set_ylabel(
"Count", fontsize = 17)
55 ax.set_title(
"Histograms of {} Normal random numbers".format(len(df.values[:, 0])), fontsize = 17)
57 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"")
58 ax.tick_params(axis =
"y", which =
"minor")
59 ax.tick_params(axis =
"x", which =
"minor")
61 plt.savefig(fileList[0].replace(
".txt",
".png"))
63 elif len(fileList) > 1:
65 sys.exit(
"Ambiguous file list exists.")
Visualization of the example output ⛓
 Test:
 test_pm_distNorm
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, Oct 16, 2009, 11:14 AM, Michigan
Definition at line 1849 of file pm_distNorm.F90.