2
2
title : stats_distribution
3
3
---
4
4
5
- # Statistical Distributions -- Normal Distribution Module
5
+ # Statistical Distributions Normal Module
6
6
7
7
[ TOC]
8
8
@@ -30,22 +30,23 @@ With three auguments, the function returns a rank one array of normal distribute
30
30
31
31
` array_size ` : optional argument has ` intent(in) ` and is a scalar of type ` integer ` .
32
32
33
- ` loc ` : optional argument has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
33
+ ` loc ` : optional argument has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
34
34
35
- ` scale ` : optional argument has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
35
+ ` scale ` : optional argument has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
36
36
37
37
` loc ` and ` scale ` arguments must have the same type.
38
38
39
39
### Return value
40
40
41
- The result is a scalar or rank one array, with a size of ` array_size ` , of type ` real ` or ` complx ` .
41
+ The result is a scalar or rank one array, with a size of ` array_size ` , of type ` real ` or ` complex ` .
42
42
43
43
### Example
44
44
45
45
``` fortran
46
46
program demo_normal_rvs
47
- use stdlib_stats_distribution_normal, only: norm => normal_distribution_rvs
48
47
use stdlib_stats_distribution_PRNG, only: random_seed
48
+ use stdlib_stats_distribution_normal, only: norm => normal_distribution_rvs
49
+
49
50
implicit none
50
51
real :: a(2,3,4), b(2,3,4)
51
52
complx :: loc, scale
@@ -65,23 +66,24 @@ program demo_normal_rvs
65
66
66
67
print *, norm(0.,1.0,10) !an array of 10 standard norml random variates
67
68
68
- ! [ -3.38123664E-02, -0.190365672, 0.220678389, -0.424612164, -0.249541596,
69
- ! 0.865260184, 1.11086845, -0.328349441, 1.10873628, 1.27049923]
69
+ ! -3.38123664E-02 -0.190365672 0.220678389 -0.424612164 -0.249541596
70
+ ! 0.865260184 1.11086845 -0.328349441 1.10873628 1.27049923
70
71
71
72
a(:,:,:) = 1.0
72
73
b(:,:,:) = 1.0
73
74
print *, norm(a,b) ! a rank 3 random variates array
74
-
75
- ![ 0.152776539, -7.51764774E-02, 1.47208166, 0.180561781, 1.32407105,
76
- ! 1.20383692, 0.123445868, -0.455737948, -0.469808221, 1.60750175,
77
- ! 1.05748117, 0.720934749, 0.407810807, 1.48165631, 2.31749439,
78
- ! 0.414566994, 3.06084275, 1.86505437, 1.36338580, 7.26878643E-02,
79
- ! 0.178585172, 1.39557445, 0.828021586, 0.872084975]
75
+
76
+ !0.152776539 -7.51764774E-02 1.47208166 0.180561781 1.32407105
77
+ ! 1.20383692 0.123445868 -0.455737948 -0.469808221 1.60750175
78
+ ! 1.05748117 0.720934749 0.407810807 1.48165631 2.31749439
79
+ ! 0.414566994 3.06084275 1.86505437 1.36338580 7.26878643E-02
80
+ ! 0.178585172 1.39557445 0.828021586 0.872084975
80
81
81
82
loc = (-1.0, 2.0)
82
83
scale = (2.0, 1.0)
83
84
print *, norm(loc, scale)
84
- !single complex normal random variate with real part of mu=-1, sigma=2; imagainary part of mu=2.0 and sigma=1.0
85
+ !single complex normal random variate with real part of miu=-1, sigma=2;
86
+ !imagainary part of miu=2.0 and sigma=1.0
85
87
86
88
! (1.22566295,2.12518454)
87
89
@@ -106,11 +108,11 @@ $$f(x)=\frac{1}{\sigma&space;\sqrt{2&space;\pi}}&space;e^{-\frac{1}{2}(\frac{x-\
106
108
107
109
### Arguments
108
110
109
- ` x ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
111
+ ` x ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
110
112
111
- ` loc ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
113
+ ` loc ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
112
114
113
- ` scale ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
115
+ ` scale ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
114
116
115
117
The function is elemental, i.e., all three auguments could be arrays conformable to each other. All three arguments must have the same type.
116
118
@@ -123,12 +125,12 @@ The result is a scalar or an array, with a shape conformable to auguments, of ty
123
125
``` fortran
124
126
program demo_normal_pdf
125
127
use stdlib_stats_distribution_PRNG, only : random_seed
126
- use stdlib_stats_distribution_normal, only : &
127
- norm_pdf=>normal_distribution_pdf,&
128
- norm => normal_distribution_rvs
128
+ use stdlib_stats_distribution_normal, only : &
129
+ norm_pdf=>normal_distribution_pdf, &
130
+ norm => normal_distribution_rvs
129
131
130
132
implicit none
131
- real :: x(2, 3,4),a(2, 3,4),b(2, 3,4)
133
+ real :: x(3,4,5 ),a(3,4,5 ),b(3,4,5 )
132
134
complx :: loc, scale
133
135
integer :: seed_put, seed_get
134
136
@@ -140,27 +142,28 @@ program demo_normal_pdf
140
142
! 0.241970733
141
143
142
144
print *, norm_pdf(2.0,-1.0, 2.0)
143
- !a probability density at 2.0 with mu =-1.0 sigma=2.0
145
+ !a probability density at 2.0 with miu =-1.0 sigma=2.0
144
146
145
147
!6.47588000E-02
146
148
147
- x = reshape(norm(0.0, 1.0, 24 ),[2, 3,4])
149
+ x = reshape(norm(0.0, 1.0, 60 ),[3,4,5 ])
148
150
! standard normal random variates array
149
151
150
152
a(:,:,:) = 0.0
151
153
b(:,:,:) = 1.0
152
154
print *, norm_pdf(x, a, b) ! standard normal probability density array
153
155
154
- ! [ 0.340346158, 0.285823315, 0.398714304, 0.391778737, 0.389345556,
155
- ! 0.364551932, 0.386712372, 0.274370432, 0.215250477, 0.378006011,
156
- ! 0.215760440, 0.177990928, 0.278640658, 0.223813817, 0.356875211,
157
- ! 0.285167664, 0.378533930, 0.390739858, 0.271684974, 0.138273031,
158
- ! 0.135456234, 0.331718773, 0.398283750, 0.383706540]
156
+ ! 0.340346158 0.285823315 0.398714304 0.391778737 0.389345556
157
+ ! 0.364551932 0.386712372 0.274370432 0.215250477 0.378006011
158
+ ! 0.215760440 0.177990928 0.278640658 0.223813817 0.356875211
159
+ ! 0.285167664 0.378533930 0.390739858 0.271684974 0.138273031
160
+ ! 0.135456234 0.331718773 0.398283750 0.383706540
159
161
160
162
loc = (1.0, -0.5)
161
163
scale = (1.0, 2.)
162
164
print *, norm_pdf((1.5,1.0), loc, scale)
163
- ! a complex normal probability density function at (1.5,1.0) with real part of mu=1.0, sigma=1.0 and imaginary part of mu=-0.5, sigma=2.0
165
+ ! a complex normal probability density function at (1.5,1.0) with real part
166
+ ! of miu=1.0, sigma=1.0 and imaginary part of miu=-0.5, sigma=2.0
164
167
165
168
! 5.30100204E-02
166
169
@@ -185,11 +188,11 @@ $$F(X)=\frac{1}{2}\left&space;[&space;1&space;+&space;erf(\frac{x-\mu}{\sqr
185
188
186
189
### Arguments
187
190
188
- ` x ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
191
+ ` x ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
189
192
190
- ` loc ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
193
+ ` loc ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
191
194
192
- ` scale ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complx ` .
195
+ ` scale ` : has ` intent(in) ` and is a scalar of type ` real ` or ` complex ` .
193
196
194
197
The function is elemental, i.e., all three auguments could be arrays conformable to each other. All three arguments must have the same type.
195
198
@@ -202,9 +205,9 @@ The result is a scalar or an array, with a shape conformable to auguments, of ty
202
205
``` fortran
203
206
program demo_norm_cdf
204
207
use stdlib_stats_distribution_PRNG, only : random_seed
205
- use stdlib_stats_distribution_normal, only : &
206
- norm_cdf => normal_distribution_cdf, &
207
- norm => normal_distribution_rvs
208
+ use stdlib_stats_distribution_normal, only : &
209
+ norm_cdf => normal_distribution_cdf, &
210
+ norm => normal_distribution_rvs
208
211
209
212
implicit none
210
213
real :: x(2,3,4),a(2,3,4),b(2,3,4)
@@ -219,7 +222,7 @@ program demo_norm_cdf
219
222
! 0.841344714
220
223
221
224
print *, norm_cdf(2.0, -1.0, 2.0)
222
- ! a cumulative at 2.0 with mu =-1 sigma=2
225
+ ! a cumulative at 2.0 with miu =-1 sigma=2
223
226
224
227
! 0.933192849
225
228
@@ -230,16 +233,17 @@ program demo_norm_cdf
230
233
b(:,:,:) = 1.0
231
234
print *, norm_cdf(x, a, b) ! standard normal cumulative array
232
235
233
- ! [ 0.713505626, 0.207069695, 0.486513376, 0.424511284, 0.587328553,
234
- ! 0.335559726, 0.401470929, 0.806552052, 0.866687536, 0.371323735,
235
- ! 0.866228044, 0.898046613, 0.198435277, 0.141147852, 0.681565762,
236
- ! 0.206268221, 0.627057910, 0.580759525, 0.190364420, 7.27325380E-02,
237
- ! 7.08068311E-02, 0.728241026, 0.522919059, 0.390097380]
236
+ ! 0.713505626 0.207069695 0.486513376 0.424511284 0.587328553
237
+ ! 0.335559726 0.401470929 0.806552052 0.866687536 0.371323735
238
+ ! 0.866228044 0.898046613 0.198435277 0.141147852 0.681565762
239
+ ! 0.206268221 0.627057910 0.580759525 0.190364420 7.27325380E-02
240
+ ! 7.08068311E-02 0.728241026 0.522919059 0.390097380
238
241
239
242
loc = (1.0,0.0)
240
243
scale = (0.5,1.0)
241
244
print *, norm_cdf((0.5,-0.5),loc,scale)
242
- !complex normal cumulative distribution at (0.5,-0.5) with real part of mu=1.0, sigma=0.5 and imaginary part of mu=0.0, sigma=1.0
245
+ !complex normal cumulative distribution at (0.5,-0.5) with real part of
246
+ !miu=1.0, sigma=0.5 and imaginary part of miu=0.0, sigma=1.0
243
247
244
248
!4.89511043E-02
245
249
0 commit comments