Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!! !!!!
4 : !!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5 : !!!! !!!!
6 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7 : !!!! !!!!
8 : !!!! This file is part of the ParaMonte library. !!!!
9 : !!!! !!!!
10 : !!!! LICENSE !!!!
11 : !!!! !!!!
12 : !!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13 : !!!! !!!!
14 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 :
17 : !> \brief
18 : !> This include file contains the implementation of procedures in [pm_distNegExp](@ref pm_distNegExp).
19 : !>
20 : !> \finmain
21 : !>
22 : !> \author
23 : !> \AmirShahmoradi, Oct 16, 2009, 11:14 AM, Michigan
24 :
25 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 :
27 : !%%%%%%%%%%%%%%%%%%%%%%
28 : #if getNegExpLogPDF_ENABLED
29 : !%%%%%%%%%%%%%%%%%%%%%%
30 :
31 2016 : if (present(mu)) then
32 2008 : if (present(invSigma)) then
33 2004 : call setNegExpLogPDF(logPDF, x, mu, invSigma, log(invSigma))
34 : else
35 4 : call setNegExpLogPDF(logPDF, x, mu)
36 : end if
37 : else
38 8 : if (present(invSigma)) then
39 4 : call setNegExpLogPDF(logPDF, x, invSigma, log(invSigma))
40 : else
41 4 : call setNegExpLogPDF(logPDF, x)
42 : end if
43 : end if
44 :
45 : !%%%%%%%%%%%%%%%%%%%%%%
46 : #elif setNegExpLogPDF_ENABLED
47 : !%%%%%%%%%%%%%%%%%%%%%%
48 :
49 : ! Validate the input.
50 :
51 : #if DDD_ENABLED || DIL_ENABLED
52 16 : CHECK_ASSERTION(__LINE__, x <= 0._RKC, SK_"@setNegExpPDF(): The condition `x <= 0._RKC` must hold. x = "//getStr(x)) ! fpp
53 : #elif MDD_ENABLED || MIL_ENABLED
54 12048 : CHECK_ASSERTION(__LINE__, x <= mu, SK_"@setNegExpPDF(): The condition `x <= mu` must hold. x = "//getStr([x, mu])) ! fpp
55 : #else
56 : #error "Unrecognized interface."
57 : #endif
58 :
59 : #if DIL_ENABLED || MIL_ENABLED
60 4016 : CHECK_ASSERTION(__LINE__, 0._RKC < invSigma, SK_"@setNegExpPDF(): The condition `0._RKC < invSigma` must hold. invSigma = "//getStr(invSigma)) ! fpp
61 12048 : CHECK_ASSERTION(__LINE__, abs(log(invSigma) - logInvSigma) < epsilon(0._RKC) * 10, SK_"@setNegExpPDF(): The condition `log(invSigma) == logInvSigma` must hold. invSigma, logInvSigma = "//getStr([invSigma, logInvSigma])) ! fpp
62 : #elif !(DDD_ENABLED || MDD_ENABLED)
63 : #error "Unrecognized interface."
64 : #endif
65 :
66 : ! Compute the PDF.
67 :
68 : #if DDD_ENABLED
69 8 : logPDF = x
70 : #elif MDD_ENABLED
71 8 : logPDF = x - mu
72 : #elif DIL_ENABLED
73 8 : logPDF = logInvSigma + x * invSigma
74 : #elif MIL_ENABLED
75 4008 : logPDF = logInvSigma + (x - mu) * invSigma
76 : #else
77 : #error "Unrecognized interface."
78 : #endif
79 :
80 : !%%%%%%%%%%%%%%%%%%%
81 : #elif getNegExpCDF_ENABLED
82 : !%%%%%%%%%%%%%%%%%%%
83 :
84 2016 : if (present(mu)) then
85 2008 : if (present(invSigma)) then
86 2004 : call setNegExpCDF(cdf, x, mu, invSigma)
87 : else
88 4 : call setNegExpCDF(cdf, x - mu)
89 : end if
90 : else
91 8 : if (present(invSigma)) then
92 4 : call setNegExpCDF(cdf, x, invSigma)
93 : else
94 4 : call setNegExpCDF(cdf, x)
95 : end if
96 : end if
97 :
98 : !%%%%%%%%%%%%%%%%%%%
99 : #elif setNegExpCDF_ENABLED
100 : !%%%%%%%%%%%%%%%%%%%
101 :
102 : ! Validate the input.
103 :
104 : #if XDD_ENABLED || XDI_ENABLED
105 20 : CHECK_ASSERTION(__LINE__, x <= 0._RKC, SK_"@setNegExpCDF(): The condition `x <= 0._RKC` must hold. x = "//getStr(x)) ! fpp
106 : #elif XMI_ENABLED
107 12024 : CHECK_ASSERTION(__LINE__, x <= mu, SK_"@setNegExpCDF(): The condition `x <= mu` must hold. x = "//getStr([x, mu])) ! fpp
108 : #else
109 : #error "Unrecognized interface."
110 : #endif
111 :
112 : #if XDI_ENABLED || XMI_ENABLED
113 4016 : CHECK_ASSERTION(__LINE__, 0._RKC < invSigma, SK_"@setNegExpCDF(): The condition `0._RKC < invSigma` must hold. invSigma = "//getStr(invSigma)) ! fpp
114 : #elif !XDD_ENABLED
115 : #error "Unrecognized interface."
116 : #endif
117 :
118 : ! Compute the CDF.
119 :
120 : #if XDD_ENABLED
121 12 : cdf = exp(x)
122 : #elif XDI_ENABLED
123 8 : cdf = exp(x * invSigma)
124 : #elif XMI_ENABLED
125 4008 : cdf = exp((x - mu) * invSigma)
126 : #else
127 : #error "Unrecognized interface."
128 : #endif
129 :
130 : !%%%%%%%%%%%%%%%%%%%%
131 : #elif getNegExpRand_ENABLED
132 : !%%%%%%%%%%%%%%%%%%%%
133 :
134 : use pm_distUnif, only: getUnifRand
135 80062 : call setNegExpRand(rand, getUnifRand(0._RKC, 1._RKC), sigma)
136 80062 : if (present(mu)) rand = rand + mu
137 :
138 : !%%%%%%%%%%%%%%%%%%%%
139 : #elif setNegExpRand_ENABLED
140 : !%%%%%%%%%%%%%%%%%%%%
141 :
142 82124 : CHECK_ASSERTION(__LINE__, 0._RKC < urand, SK_"@setNegExpRand(): The condition `0._RKC < urand` must hold. urand = "//getStr(urand)) ! fpp
143 82124 : CHECK_ASSERTION(__LINE__, urand <= 1._RKC, SK_"@setNegExpRand(): The condition `urand <= 1._RKC` must hold. urand = "//getStr(urand)) ! fpp
144 : #if USD_ENABLED || USM_ENABLED
145 82093 : CHECK_ASSERTION(__LINE__, 0._RKC < sigma, SK_"@setNegExpRand(): The condition `0._RKC < sigma` must hold. sigma = "//getStr(sigma)) ! fpp
146 : #endif
147 : #if UDD_ENABLED
148 31 : rand = log(1._RKC - urand)
149 : #elif USD_ENABLED
150 80093 : rand = log(1._RKC - urand) * sigma
151 : #elif USM_ENABLED
152 2000 : rand = log(1._RKC - urand) * sigma + mu
153 : #else
154 : #error "Unrecognized interface."
155 : #endif
156 :
157 : #else
158 : !%%%%%%%%%%%%%%%%%%%%%%%%
159 : #error "Unrecognized interface."
160 : !%%%%%%%%%%%%%%%%%%%%%%%%
161 : #endif
|