Skip to content

Commit 7b27e63

Browse files
author
Jim-215-Fisher
committed
add normal distribution
1 parent 2ad9b06 commit 7b27e63

9 files changed

+312
-797
lines changed

doc/specs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This is and index/directory of the specifications (specs) for each new module/fe
2525
- [sorting](./stdlib_sorting.html) - Sorting of rank one arrays
2626
- [stats](./stdlib_stats.html) - Descriptive Statistics
2727
- [stats_distributions_uniform](./stdlib_stats_distribution_uniform.html) - Uniform Probability Distribution
28+
- [stats_distributions_normal](./stdlib_stats_distribution_normal.html) - Normal Probability Distribution
2829
- [string\_type](./stdlib_string_type.html) - Basic string support
2930
- [strings](./stdlib_strings.html) - String handling and manipulation routines
3031
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings

doc/specs/stdlib_stats_distribution_normal.md

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: stats_distribution
2+
title: stats_distribution_normal
33
---
44

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

77
[TOC]
88

9-
## `normal_distribution_rvs` - normal distribution random variates
9+
## `rvs_normal` - normal distribution random variates
1010

1111
### Status
1212

@@ -16,15 +16,19 @@ Experimental
1616

1717
A normal continuous random variate distribution, also known as Gaussian, or Gauss or Laplace-Gauss distribution. The location `loc` specifies the mean or expectation. The `scale` specifies the standard deviation.
1818

19-
Without augument the function returns a standard normal distributed random variate N(0,1). The function is elemental.
19+
Without argument the function returns a standard normal distributed random variate N(0,1).
2020

21-
With two arguments, the function returns a normal distributed random variate N(loc, scale^2). For complex auguments, the real and imaginary parts are independent of each other. The function is elemental.
21+
With two arguments, the function returns a normal distributed random variate N(loc, scale^2). For complex arguments, the real and imaginary parts are independent of each other.
2222

23-
With three auguments, the function returns a rank one array of normal distributed random variates.
23+
With three arguments, the function returns a rank one array of normal distributed random variates.
2424

2525
### Syntax
2626

27-
`result = [[stdlib_stats_distribution_normal(module):normal_distribution_rvs(interface)]]([loc, scale] [[, array_size]])`
27+
`result = [[stdlib_stats_distribution_normal(module):rvs_normal(interface)]]([loc, scale] [[, array_size]])`
28+
29+
### Class
30+
31+
Function
2832

2933
### Arguments
3034

@@ -44,8 +48,8 @@ The result is a scalar or rank one array, with a size of `array_size`, of type `
4448

4549
```fortran
4650
program demo_normal_rvs
47-
use stdlib_stats_distribution_PRNG, only: random_seed
48-
use stdlib_stats_distribution_normal, only: norm => normal_distribution_rvs
51+
use stdlib_random, only: random_seed
52+
use stdlib_stats_distribution_normal, only: norm => rvs_normal
4953
5054
implicit none
5155
real :: a(2,3,4), b(2,3,4)
@@ -90,7 +94,7 @@ program demo_normal_rvs
9094
end program demo_normal_rvs
9195
```
9296

93-
## `normal_distribution_pdf` - normal probability density function
97+
## `pdf_normal` - normal distribution probability density function
9498

9599
### Status
96100

@@ -100,11 +104,15 @@ Experimental
100104

101105
The probability density function of the continuous normal distribution.
102106

103-
$$f(x)=\frac{1}{\sigma&space;\sqrt{2&space;\pi}}&space;e^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^{2}})$$
107+
$$f(x) = \frac{1}{\sigma \sqrt{2}} e^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^{2}}$$
104108

105109
### Syntax
106110

107-
`result = [[stdlib_stats_distribution_normal(module):normal_distribution_pdf(interface)]](x, loc, scale)`
111+
`result = [[stdlib_stats_distribution_normal(module):pdf_normal(interface)]](x, loc, scale)`
112+
113+
### Class
114+
115+
Elemental function
108116

109117
### Arguments
110118

@@ -114,20 +122,19 @@ $$f(x)=\frac{1}{\sigma&space;\sqrt{2&space;\pi}}&space;e^{-\frac{1}{2}(\frac{x-\
114122

115123
`scale`: has `intent(in)` and is a scalar of type `real` or `complex`.
116124

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.
125+
All three arguments must have the same type.
118126

119127
### Return value
120128

121-
The result is a scalar or an array, with a shape conformable to auguments, of type `real`.
129+
The result is a scalar or an array, with a shape conformable to arguments, of type `real`.
122130

123131
### Example
124132

125133
```fortran
126134
program demo_normal_pdf
127-
use stdlib_stats_distribution_PRNG, only : random_seed
128-
use stdlib_stats_distribution_normal, only : &
129-
norm_pdf=>normal_distribution_pdf, &
130-
norm => normal_distribution_rvs
135+
use stdlib_random, only : random_seed
136+
use stdlib_stats_distribution_normal, only : norm_pdf=>pdf_normal, &
137+
norm => rvs_normal
131138
132139
implicit none
133140
real :: x(3,4,5),a(3,4,5),b(3,4,5)
@@ -170,7 +177,7 @@ program demo_normal_pdf
170177
end program demo_normal_pdf
171178
```
172179

173-
## `normal_distribution_cdf` - normal cumulative distribution function
180+
## `cdf_normal` - normal distribution cumulative distribution function
174181

175182
### Status
176183

@@ -180,11 +187,15 @@ Experimental
180187

181188
Cumulative distribution function of the normal continuous distribution
182189

183-
$$F(X)=\frac{1}{2}\left&space;[&space;1&space;+&space;erf(\frac{x-\mu}{\sqrt{2}&space;\sigma})&space;\right&space;])$$
190+
$$F(x)=\frac{1}{2}\left [ 1+erf(\frac{x-\mu}{\sigma \sqrt{2}}) \right ]$$
184191

185192
### Syntax
186193

187-
`result = [[stdlib_stats_distribution_normal(module):normal_distribution_cdf(interface)]](x, loc, scale)`
194+
`result = [[stdlib_stats_distribution_normal(module):cdf_normal(interface)]](x, loc, scale)`
195+
196+
### Class
197+
198+
Elemental function
188199

189200
### Arguments
190201

@@ -194,20 +205,19 @@ $$F(X)=\frac{1}{2}\left&space;[&space;1&space;+&space;erf(\frac{x-\mu}{\sqr
194205

195206
`scale`: has `intent(in)` and is a scalar of type `real` or `complex`.
196207

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.
208+
All three arguments must have the same type.
198209

199210
### Return value
200211

201-
The result is a scalar or an array, with a shape conformable to auguments, of type `real`.
212+
The result is a scalar or an array, with a shape conformable to arguments, of type `real`.
202213

203214
### Example
204215

205216
```fortran
206217
program demo_norm_cdf
207-
use stdlib_stats_distribution_PRNG, only : random_seed
208-
use stdlib_stats_distribution_normal, only : &
209-
norm_cdf => normal_distribution_cdf, &
210-
norm => normal_distribution_rvs
218+
use stdlib_random, only : random_seed
219+
use stdlib_stats_distribution_normal, only : norm_cdf => cdf_normal, &
220+
norm => rvs_normal
211221
212222
implicit none
213223
real :: x(2,3,4),a(2,3,4),b(2,3,4)

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set(fppFiles
2525
stdlib_stats_moment_mask.fypp
2626
stdlib_stats_moment_scalar.fypp
2727
stdlib_stats_distribution_uniform.fypp
28+
stdlib_stats_distribution_normal.fypp
2829
stdlib_stats_var.fypp
2930
stdlib_quadrature.fypp
3031
stdlib_quadrature_trapz.fypp

src/Makefile.manual

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SRCFYPP = \
2727
stdlib_stats_moment_mask.fypp \
2828
stdlib_stats_moment_scalar.fypp \
2929
stdlib_stats_distribution_uniform.fypp \
30+
stdlib_stats_distribution_normal.fypp \
3031
stdlib_stats_var.fypp \
3132
stdlib_math.fypp \
3233
stdlib_math_linspace.fypp \
@@ -150,6 +151,11 @@ stdlib_stats_distribution_uniform.o: \
150151
stdlib_kinds.o \
151152
stdlib_error.o \
152153
stdlib_random.o
154+
stdlib_stats_distribution_normal.o: \
155+
stdlib_kinds.o \
156+
stdlib_error.o \
157+
stdlib_random.o \
158+
stdlib_stats_distribution_uniform.o
153159
stdlib_random.o: \
154160
stdlib_kinds.o \
155161
stdlib_error.o

src/stdlib_stats_distribution_PRNG.fypp

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)