Skip to content

Commit 5158fe1

Browse files
Add files via upload
1 parent da63c88 commit 5158fe1

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

doc/specs/stdlib_stats_distribution_normal.md

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: stats_distribution
33
---
44

5-
# Statistical Distributions -- Normal Distribution Module
5+
# Statistical Distributions Normal Module
66

77
[TOC]
88

@@ -30,22 +30,23 @@ With three auguments, the function returns a rank one array of normal distribute
3030

3131
`array_size`: optional argument has `intent(in)` and is a scalar of type `integer`.
3232

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`.
3434

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`.
3636

3737
`loc` and `scale` arguments must have the same type.
3838

3939
### Return value
4040

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`.
4242

4343
### Example
4444

4545
```fortran
4646
program demo_normal_rvs
47-
use stdlib_stats_distribution_normal, only: norm => normal_distribution_rvs
4847
use stdlib_stats_distribution_PRNG, only: random_seed
48+
use stdlib_stats_distribution_normal, only: norm => normal_distribution_rvs
49+
4950
implicit none
5051
real :: a(2,3,4), b(2,3,4)
5152
complx :: loc, scale
@@ -65,23 +66,24 @@ program demo_normal_rvs
6566
6667
print *, norm(0.,1.0,10) !an array of 10 standard norml random variates
6768
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
7071
7172
a(:,:,:) = 1.0
7273
b(:,:,:) = 1.0
7374
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
8081
8182
loc = (-1.0, 2.0)
8283
scale = (2.0, 1.0)
8384
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
8587
8688
! (1.22566295,2.12518454)
8789
@@ -106,11 +108,11 @@ $$f(x)=\frac{1}{\sigma&space;\sqrt{2&space;\pi}}&space;e^{-\frac{1}{2}(\frac{x-\
106108

107109
### Arguments
108110

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`.
110112

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`.
112114

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`.
114116

115117
The function is elemental, i.e., all three auguments could be arrays conformable to each other. All three arguments must have the same type.
116118

@@ -123,12 +125,12 @@ The result is a scalar or an array, with a shape conformable to auguments, of ty
123125
```fortran
124126
program demo_normal_pdf
125127
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
129131
130132
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)
132134
complx :: loc, scale
133135
integer :: seed_put, seed_get
134136
@@ -140,27 +142,28 @@ program demo_normal_pdf
140142
! 0.241970733
141143
142144
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
144146
145147
!6.47588000E-02
146148
147-
x = reshape(norm(0.0, 1.0, 24),[2,3,4])
149+
x = reshape(norm(0.0, 1.0, 60),[3,4,5])
148150
! standard normal random variates array
149151
150152
a(:,:,:) = 0.0
151153
b(:,:,:) = 1.0
152154
print *, norm_pdf(x, a, b) ! standard normal probability density array
153155
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
159161
160162
loc = (1.0, -0.5)
161163
scale = (1.0, 2.)
162164
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
164167
165168
! 5.30100204E-02
166169
@@ -185,11 +188,11 @@ $$F(X)=\frac{1}{2}\left&space;[&space;1&space;+&space;erf(\frac{x-\mu}{\sqr
185188

186189
### Arguments
187190

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`.
189192

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`.
191194

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`.
193196

194197
The function is elemental, i.e., all three auguments could be arrays conformable to each other. All three arguments must have the same type.
195198

@@ -202,9 +205,9 @@ The result is a scalar or an array, with a shape conformable to auguments, of ty
202205
```fortran
203206
program demo_norm_cdf
204207
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
208211
209212
implicit none
210213
real :: x(2,3,4),a(2,3,4),b(2,3,4)
@@ -219,7 +222,7 @@ program demo_norm_cdf
219222
! 0.841344714
220223
221224
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
223226
224227
! 0.933192849
225228
@@ -230,16 +233,17 @@ program demo_norm_cdf
230233
b(:,:,:) = 1.0
231234
print *, norm_cdf(x, a, b) ! standard normal cumulative array
232235
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
238241
239242
loc = (1.0,0.0)
240243
scale = (0.5,1.0)
241244
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
243247
244248
!4.89511043E-02
245249

0 commit comments

Comments
 (0)