Skip to content

Commit ed7c2cb

Browse files
author
Jim-215-Fisher
committed
modify for complex case
1 parent c4d1391 commit ed7c2cb

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

doc/specs/stdlib_stats_distribution_normal.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ Experimental
102102

103103
### Description
104104

105-
The probability density function of the continuous normal distribution.
105+
The probability density function (pdf) of the single real variable normal distribution:
106106

107107
$$f(x) = \frac{1}{\sigma \sqrt{2}} e^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^{2}}$$
108108

109+
For complex varible (x + y i) with independent real x and imaginary y parts, the joint probability density function is the product of corresponding marginal pdf of real and imaginary pdf (ref. "Probability and Random Processes with Applications to Signal Processing and Communications", 2nd ed., Scott L. Miller and Donald Childers, 2012, p.197):
110+
111+
$$f(x + y \mathit{i}) = f(x) f(y) = \frac{1}{2\sigma_{x}\sigma_{y}} e^{-\frac{1}{2}[(\frac{x-\mu}{\sigma_{x}})^{2}+(\frac{y-\nu}{\sigma_{y}})^{2}]}$$
112+
109113
### Syntax
110114

111115
`result = [[stdlib_stats_distribution_normal(module):pdf_normal(interface)]](x, loc, scale)`
@@ -185,10 +189,14 @@ Experimental
185189

186190
### Description
187191

188-
Cumulative distribution function of the normal continuous distribution
192+
Cumulative distribution function of the single real variable normal distribution:
189193

190194
$$F(x)=\frac{1}{2}\left [ 1+erf(\frac{x-\mu}{\sigma \sqrt{2}}) \right ]$$
191195

196+
For the complex variable (x + y i) with independent real x and imaginary y parts, the joint cumulative distribution function is the product of corresponding marginal cdf of real and imaginary cdf (ref. "Probability and Random Processes with Applications to Signal Processing and Communications", 2nd ed., Scott L. Miller and Donald Childers, 2012, p.197):
197+
198+
$$F(x+y\mathit{i})=F(x)F(y)=\frac{1}{4} [1+erf(\frac{x-\mu}{\sigma_{x} \sqrt{2}})] [1+erf(\frac{y-\nu}{\sigma_{y} \sqrt{2}})]$$
199+
192200
### Syntax
193201

194202
`result = [[stdlib_stats_distribution_normal(module):cdf_normal(interface)]](x, loc, scale)`

src/stdlib_stats_distribution_normal.fypp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ contains
7474

7575
subroutine zigset
7676
! Marsaglia & Tsang generator for random normals & random exponentials.
77-
! Translated from C by Alan Miller ([email protected])
77+
! Translated from C by Alan Miller ([email protected]), released as public
78+
! domain (https://jblevins.org/mirror/amiller/)
7879
!
7980
! Marsaglia, G. & Tsang, W.W. (2000) `The ziggurat method for generating
8081
! random variables', J. Statist. Software, v5(8).

src/tests/stats/test_distribution_normal.fypp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#:include "common.fypp"
33
#:set RC_KINDS_TYPES = REAL_KINDS_TYPES + CMPLX_KINDS_TYPES
44
program test_distribution_normal
5-
use stdlib_kinds
5+
use stdlib_kinds, only : sp, dp, qp
66
use stdlib_error, only : check
77
use stdlib_random, only : random_seed
88
use stdlib_stats_distribution_uniform, only : uni => rvs_uniform
@@ -63,7 +63,7 @@ contains
6363
chisq = chisq + (freq(i) - expct) ** 2 / expct
6464
end do
6565
write(*,*) "The critical values for chi-squared with 1000 d. of f. is" &
66-
//" 1143.92"
66+
//" 1143.92"
6767
write(*,*) "Chi-squared for normal random generator is : ", chisq
6868
call check((chisq < 1143.9), &
6969
msg = "normal randomness failed chi-squared test", warn = warn)

0 commit comments

Comments
 (0)