@@ -4,60 +4,72 @@ program example_exponential_cdf
44 rexp = > rvs_exp
55
66 implicit none
7- real , dimension (2 , 3 , 4 ) :: x, lambda
7+ real , dimension (2 , 3 , 4 ) :: x, loc, scale
88 real :: xsum
9- complex :: scale
9+ complex :: cloc, cscale
1010 integer :: seed_put, seed_get, i
1111
1212 seed_put = 1234567
1313 call random_seed (seed_put, seed_get)
1414
15- ! standard exponential cumulative distribution at x=1.0
16- print * , exp_cdf(1.0 , 1.0 )
15+ ! standard exponential cumulative distribution at x=1.0 with loc=0.0, scale=1.0
16+ print * , exp_cdf(1.0 , 0.0 , 1.0 )
1717 ! 0.632120550
1818
19- ! cumulative distribution at x=2.0 with lambda=2
20- print * , exp_cdf(2.0 , 2.0 )
19+ ! cumulative distribution at x=2.0 with loc=0.0 and scale=0.5 (equivalent of lambda=2)
20+ print * , exp_cdf(2.0 , 0.0 , 0.5 )
2121 ! 0.981684387
2222
23- ! cumulative distribution at x=2.0 with lambda=-1.0 (out of range)
24- print * , exp_cdf(2.0 , - 1.0 )
23+ ! cumulative distribution at x=2.5 with loc=0.5 and scale=0.5 (equivalent of lambda=2)
24+ print * , exp_cdf(2.5 , 0.5 , 0.5 )
25+ ! 0.981684387
26+
27+ ! cumulative distribution at x=2.0 with loc=0.0 and scale=-1.0 (out of range)
28+ print * , exp_cdf(2.0 , 0.0 , - 1.0 )
2529 ! NaN
2630
31+ ! cumulative distribution at x=0.5 with loc=1.0 and scale=1.0, putting x below the minimum
32+ print * , exp_cdf(0.5 , 1.0 , 1.0 )
33+ ! 0.00000000
34+
2735 ! standard exponential random variates array
28- x = reshape (rexp(0.5 , 24 ), [2 , 3 , 4 ])
36+ x = reshape (rexp(0.0 , 2.0 , 24 ), [2 , 3 , 4 ])
2937
3038 ! a rank-3 exponential cumulative distribution
31- lambda(:, :, :) = 0.5
32- print * , exp_cdf(x, lambda)
39+ loc(:, :, :) = 0.0
40+ scale (:, :, :) = 2.0
41+ print * , exp_cdf(x, loc, scale)
3342 ! 0.301409245 0.335173965 5.94930053E-02 0.113003314
3443 ! 0.365694344 0.583515942 0.113774836 0.838585377
3544 ! 0.509324908 0.127967060 0.857194781 0.893231630
3645 ! 0.355383813 0.470882893 0.574203610 0.799321830
3746 ! 0.546216846 0.111995399 0.801794767 0.922525287
38- ! 0.937719882 0.301136374 3.44503522E-02 0.134661376
47+ ! 0.937719882 0.301136374 3.44503522E-02 0.134661376
48+
3949
40- ! cumulative distribution array where lambda <=0.0 for certain elements
41- print * , exp_cdf([1.0 , 1.0 , 1.0 ], [1.0 , 0.0 , - 1.0 ])
50+ ! cumulative distribution array where scale <=0.0 for certain elements
51+ print * , exp_cdf([1.0 , 1.0 , 1.0 ], [0.0 , 0.0 , 0.0 ], [ 1.0 , 0.0 , - 1.0 ])
4252 ! 0.632120550 NaN NaN
4353
44- ! `cdf_exp` is pure and, thus, can be called concurrently
54+ ! `cdf_exp` is pure and, thus, can be called concurrently
4555 xsum = 0.0
4656 do concurrent (i= 1 :size (x,3 ))
47- xsum = xsum + sum (exp_cdf(x(:,:,i), lambda (:,:,i)))
57+ xsum = xsum + sum (exp_cdf(x(:,:,i), loc(:,:,i), scale (:,:,i)))
4858 end do
4959 print * , xsum
5060 ! 11.0886612
5161
52- ! complex exponential cumulative distribution at (0.5,0.5) with real part of
53- ! lambda=0.5 and imaginary part of lambda=1.0
54- scale = (0.5 , 1.0 )
55- print * , exp_cdf((0.5 , 0.5 ), scale)
62+ ! complex exponential cumulative distribution at (0.5, 0.0, 2) with real part of
63+ ! scale=2 and imaginary part of scale=1.0
64+ cloc = (0.0 , 0.0 )
65+ cscale = (2 , 1.0 )
66+ print * , exp_cdf((0.5 , 0.5 ), cloc, cscale)
5667 ! 8.70351046E-02
5768
58- ! As above, but with lambda%im < 0
59- scale = (1.0 , - 2.0 )
60- print * , exp_cdf((1.5 , 1.0 ), scale)
69+ ! As above, but with scale%im < 0
70+ cloc = (0.0 , 0.0 )
71+ cscale = (1.0 , - 2.0 )
72+ print * , exp_cdf((1.5 , 1.0 ), cloc, cscale)
6173 ! NaN
6274
6375end program example_exponential_cdf
0 commit comments