Generate and return the natural logarithm of the NormShell density function value(s) at the specified input point X
, for the specified set of parameters of the single or mixture of NormShell distributions.
More...
Generate and return the natural logarithm of the NormShell density function value(s) at the specified input point X
, for the specified set of parameters of the single or mixture of NormShell distributions.
See the documentation of pm_distNormShell for details of the NormShell density function.
- Parameters
-
[in] | X | : The input vector of size (1:ndim) of,
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the ndim -dimensional point at which the function must be evaluated. |
[in] | center | : The input argument of the same type and kind as X , representing the center (location parameter: \(\mu\)) of the density function(s).
It can be,
-
a
contiguous vector of the same rank and size as the input X : center(1:ndim) .
-
a
contiguous matrix whose first dimension is of the same size as the input X , and its second dimension is the number of unique density functions in the mixture: center(1:ndim, 1:nmix) .
(optional, default = 0. . It must be present if and only if the input argument invCov is also present.) |
[in] | invCov | : The input argument of the same type and kind as X , representing the inverse covariance matrix(es) ( \(\Sigma^{-1}\)) of the Normal distribution(s) of the density function(s).
It can be,
-
a
contiguous square matrix of the same rank as the size of the input X : invCov(1:ndim, 1:ndim) .
-
a
contiguous array of rank 3 whose first and second dimensions are of the same size as the input X , and its third dimension is the number of unique density functions in the mixture: invCov(1:ndim, 1:ndim, 1:nmix) .
(optional, default = the identity matrix. It must be present if and only if the input argument center is also present.) |
[in] | width | : The input positive-valued argument of the same type and kind as the input X , representing the width of the shell(s) as specified by the shape parameter ( \(\omega\)) of the density function(s).
It can be,
-
a scalar representing the width of the single density function.
-
a
contiguous vector of size nmix , representing the widths of individual density function(s) in the mixture.
(optional, default = 1. ) |
[in] | radius | : The input positive-valued argument of the same type and kind as the input X , representing the radius of the shell(s) as specified by the shape parameter ( \(\rho\)) of the density function(s).
It can be,
-
a scalar representing the radius of the single density function.
-
a
contiguous vector of size nmix , representing the radii of individual density function(s) in the mixture.
(optional, default = 1. ) |
- Returns
logUDF
: The output of the same type and kind as the input argument X
representing the natural logarithm of the value(s) of the density function(s) at the specified location X
and parameters sets.
It is,
-
a scalar if and only if the dimensionality of the input arguments corresponds to a single density function.
-
a vector of size
nmix
if and only if the dimensionality of the input arguments corresponds to a mixture of nmix
density functions.
Possible calling interfaces ⛓
logUDF
= getNormShellLogUDF(X(
1:ndim), center(
1:ndim), invCov(
1:ndim,
1:ndim), width
= width, radius
= radius)
logUDF(
1:nmix)
= getNormShellLogUDF(X(
1:ndim), width
= width(
1:nmix), radius
= radius(
1:nmix))
logUDF(
1:nmix)
= getNormShellLogUDF(X(
1:ndim), center(
1:ndim,
1:nmix), invCov(
1:ndim,
1:ndim,
1:nmix), width
= width(
1:nmix), radius
= radius(
1:nmix))
Generate and return the natural logarithm of the NormShell density function value(s) at the specified...
This module contains procedures and generic interfaces for computing the Multivariate Normal Shell de...
- Warning
- The condition
all([0. < width])
must hold for the corresponding input arguments.
The condition all([0. < radius])
must hold for the corresponding input arguments.
The condition size(X, 1) == size(center, 1)
must hold for the corresponding input arguments.
The condition all(size(X, 1) == [size(invCov, 1), size(invCov, 2)])
must hold for the corresponding input arguments.
The condition size(invCov, rank(invCov)) == size(center, rank(invCov))
must 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 ⛓
13 integer(IK),
parameter :: NP
= 5_IK
15 type(display_type) :: disp
19 call disp%show(
"getNormShellLogUDF([0._RKG]) ! 1D")
24 call disp%show(
"getNormShellLogUDF([0._RKG], [0._RKG], reshape([1._RKG], [1,1]), 5._RKG, 2._RKG) ! 1D")
29 call disp%show(
"getNormShellLogUDF([real(RKG) :: 0, 1], center = [-1._RKG, 1._RKG], invCov = reshape([1._RKG, .5_RKG, .5_RKG, 1._RKG], [2, 2]), width = 0.5_RKG, radius = 2._RKG) ! 2D")
30 call disp%show(
getNormShellLogUDF([
real(RKG) ::
0,
1], center
= [
-1._RKG,
1._RKG], invCov
= reshape([
1._RKG, .
5_RKG, .
5_RKG,
1._RKG], [
2,
2]), width
= 0.5_RKG, radius
= 2._RKG) )
38 integer(IK) :: fileUnit, i, j
39 integer(IK),
parameter :: nmix
= 4
40 real(RKG) ,
parameter :: signif
= 2
41 real(RKG) :: point(
1000), width(nmix), radius(nmix), center(
1, nmix), invCov(
1,
1, nmix)
42 center
= reshape([
-1._RKG,
+0._RKG,
+1._RKG,
+2._RKG],
shape(center))
43 invCov
= 1._RKG / reshape([
+1._RKG,
+2._RKG,
+5._RKG,
0.5_RKG],
shape(invCov))
44 radius
= [
1._RKG,
5._RKG,
2._RKG,
0.5_RKG]
50 open(newunit
= fileUnit, file
= "getNormShellLogUDF.D1.RK.txt")
52 write(fileUnit,
"(*(f0.8,:,','))") point(i),
exp(
getNormShellLogUDF(point(i:i), center, invCov, width, radius))
62 integer(IK) :: fileUnit, i, j
63 real(RKG) ,
parameter :: signif
= 2_IK
64 integer(IK) ,
parameter :: ndim
= 2_IK, nmix
= 2_IK, npnt
= 700_IK
65 real(RKG) :: grid(ndim, npnt, npnt), center(ndim, nmix), invCov(ndim, ndim, nmix), width(nmix), radius(nmix)
66 center
= 2 * reshape([
-1._RKG,
-1._RKG,
1._RKG,
1._RKG],
shape(center))
67 invCov
= spread(
getMatInit([ndim, ndim], uppLowDia,
0._RKG,
0._RKG,
1._RKG),
3, nmix)
70 radius
= [
2._RKG,
2._RKG]
71 width
= .
5_RKG * [
1._RKG,
1._RKG]
73 grid(i, :, :)
= spread(
getLinSpace(x1
= -6._RKG, x2
= +6._RKG, count
= npnt) ,
3 - i, npnt)
75 open(newunit
= fileUnit, file
= "getNormShellLogUDF.D2.RK.txt")
76 do i
= 1,
size(grid,
2)
77 do j
= 1,
size(grid,
3)
78 write(fileUnit,
"(*(f0.8,:,','))") grid(:, i, j),
exp(
getLogSumExp(
getNormShellLogUDF(grid(:, i, j), center, invCov, width, radius)))
Generate count evenly spaced points over the interval [x1, x2] if x1 < x2, or [x2,...
Return the linSpace output argument with size(linSpace) elements of evenly-spaced values over the int...
Return the logSpace output argument with size(logSpace) elements of logarithmically-evenly-spaced 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.
Generate and return the natural logarithm of the sum of the exponential of the input array robustly (...
Generate and return a matrix of shape (shape(1), shape(2)) with the upper/lower triangle and the diag...
This module contains procedures and generic interfaces for assessing whether particular value(s) or a...
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 RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
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...
This module contains the procedures and interfaces for computing the natural logarithm of the sum of ...
This module contains procedures and generic interfaces for evaluating the mathematical operator acti...
This module contains procedures and generic interfaces relevant to generating and initializing matric...
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 ⛓
10getNormShellLogUDF([
real(RKG) ::
0,
1], center
= [
-1._RKG,
1._RKG], invCov
= reshape([
1._RKG, .
5_RKG, .
5_RKG,
1._RKG], [
2,
2]), width
= 0.5_RKG, radius
= 2._RKG)
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
17xlab = {
"CK" :
"X ( real/imaginary components )"
18 ,
"IK" :
"X ( integer-valued )"
19 ,
"RK" :
"X ( real-valued )"
21legends = [
r"$\mu = -1.,~\Sigma = 1., \omega = .5, \rho = 1.$"
22 ,
r"$\mu = +0.,~\Sigma = 2., \omega = .5, \rho = 5.$"
23 ,
r"$\mu = +1.,~\Sigma = 5., \omega = .5, \rho = 2.$"
24 ,
r"$\mu = +2.,~\Sigma = .5, \omega = .5, \rho = .5$"
27for kind
in [
"IK",
"CK",
"RK"]:
31 pattern =
"*.D1."+kind+
".txt"
32 fileList = glob.glob(pattern)
33 if len(fileList) == 1:
35 df = pd.read_csv(fileList[0], delimiter =
",")
37 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 300)
41 plt.plot( df.values[:, 0]
44 , linewidth = linewidth
47 plt.plot( df.values[:, 1]
50 , linewidth = linewidth
54 plt.plot( df.values[:, 0]
57 , linewidth = linewidth
64 plt.xticks(fontsize = fontsize - 2)
65 plt.yticks(fontsize = fontsize - 2)
66 ax.set_xlabel(xlab[kind], fontsize = 17)
67 ax.set_ylabel(
"Probability Density Function (PDF)", fontsize = 17)
69 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
70 ax.tick_params(axis =
"y", which =
"minor")
71 ax.tick_params(axis =
"x", which =
"minor")
74 plt.savefig(fileList[0].replace(
".txt",
".png"))
76 elif len(fileList) > 1:
78 sys.exit(
"Ambiguous file list exists.")
81 pattern =
"*.D2."+kind+
".txt"
82 fileList = glob.glob(pattern)
83 if len(fileList) == 1:
85 df = pd.read_csv(fileList[0], delimiter =
",", header =
None)
88 npnt = math.isqrt(len(df[:, 0]))
89 gridx = np.reshape(df[:, 0], newshape = (npnt, npnt), order =
'F')
90 gridy = np.reshape(df[:,1], newshape = (npnt, npnt), order =
'F')
91 gridz = np.reshape(df[:,2], newshape = (npnt, npnt), order =
'C')
93 fig, ax = plt.subplots(subplot_kw = {
"projection":
"3d"})
94 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 300)
95 ax = fig.add_subplot(1, 1, 1, projection =
'3d')
97 ax.plot_surface(gridx, gridy, gridz, cmap =
'viridis', linewidth = 0)
98 ax.set_xlabel(
'X axis')
99 ax.set_ylabel(
'Y axis')
100 ax.set_zlabel(
"Log ( Density )", fontsize = 17)
102 plt.xticks(fontsize = fontsize - 2)
103 plt.yticks(fontsize = fontsize - 2)
105 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
106 ax.tick_params(axis =
"y", which =
"minor")
107 ax.tick_params(axis =
"x", which =
"minor")
110 plt.savefig(fileList[0].replace(
".txt",
".png"))
112 elif len(fileList) > 1:
114 sys.exit(
"Ambiguous file list exists.")
Visualization of the example output ⛓
- Test:
- test_pm_distNormShell
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 161 of file pm_distNormShell.F90.