Skip to content

Commit 94ed13f

Browse files
committed
pdf and cdf should be zero if x<0
1 parent 47dfe53 commit 94ed13f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/stdlib_stats_distribution_exponential.fypp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,10 @@ contains
265265
${t1}$, intent(in) :: x, lambda
266266
real(${k1}$) :: res
267267

268-
if ((lambda <= 0._${k1}$) .or. (x < 0._${k1}$)) then
268+
if (lambda <= 0._${k1}$) then
269269
res = ieee_value(1._${k1}$, ieee_quiet_nan)
270+
else if (x < 0._${k1}$) then
271+
res = 0._${k1}$
270272
else
271273
res = exp(- x * lambda) * lambda
272274
end if
@@ -299,8 +301,10 @@ contains
299301
${t1}$, intent(in) :: x, lambda
300302
real(${k1}$) :: res
301303

302-
if ((lambda <= 0._${k1}$) .or. (x < 0._${k1}$)) then
304+
if (lambda <= 0._${k1}$) then
303305
res = ieee_value(1._${k1}$, ieee_quiet_nan)
306+
else if (x < 0._${k1}$) then
307+
res = 0._${k1}$
304308
else
305309
res = 1.0_${k1}$ - exp(- x * lambda)
306310
end if

0 commit comments

Comments
 (0)