@@ -4,60 +4,72 @@ program example_exponential_cdf
4
4
rexp = > rvs_exp
5
5
6
6
implicit none
7
- real , dimension (2 , 3 , 4 ) :: x, lambda
7
+ real , dimension (2 , 3 , 4 ) :: x, loc, scale
8
8
real :: xsum
9
- complex :: scale
9
+ complex :: cloc, cscale
10
10
integer :: seed_put, seed_get, i
11
11
12
12
seed_put = 1234567
13
13
call random_seed (seed_put, seed_get)
14
14
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 )
17
17
! 0.632120550
18
18
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 )
21
21
! 0.981684387
22
22
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 )
25
29
! NaN
26
30
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
+
27
35
! 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 ])
29
37
30
38
! 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)
33
42
! 0.301409245 0.335173965 5.94930053E-02 0.113003314
34
43
! 0.365694344 0.583515942 0.113774836 0.838585377
35
44
! 0.509324908 0.127967060 0.857194781 0.893231630
36
45
! 0.355383813 0.470882893 0.574203610 0.799321830
37
46
! 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
+
39
49
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 ])
42
52
! 0.632120550 NaN NaN
43
53
44
- ! `cdf_exp` is pure and, thus, can be called concurrently
54
+ ! `cdf_exp` is pure and, thus, can be called concurrently
45
55
xsum = 0.0
46
56
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)))
48
58
end do
49
59
print * , xsum
50
60
! 11.0886612
51
61
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)
56
67
! 8.70351046E-02
57
68
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)
61
73
! NaN
62
74
63
75
end program example_exponential_cdf
0 commit comments