Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probability Distribution and Statistical Functions -- Uniform Distribution Module #272

Merged
merged 193 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 178 commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
edf8e54
change in Makefile.manual
Jim-215-Fisher Oct 18, 2020
322a3a8
Add files via upload
Jim-215-Fisher Dec 20, 2020
4b336de
initial commit
Jim-215-Fisher Dec 20, 2020
1664d42
initial commit
Jim-215-Fisher Dec 20, 2020
dbb7de7
Add files via upload
Jim-215-Fisher Dec 20, 2020
d3214fc
correct file
Jim-215-Fisher Dec 20, 2020
7d30492
convert % complex representation to real() and aimag() representation
Jim-215-Fisher Dec 20, 2020
0d3b59f
Convert complex representation
Jim-215-Fisher Dec 20, 2020
3987d62
Convert complex number representtion
Jim-215-Fisher Dec 20, 2020
98e3d48
remove tab
Jim-215-Fisher Dec 20, 2020
b714194
remove tab
Jim-215-Fisher Dec 20, 2020
49f9d89
minor change
Jim-215-Fisher Dec 20, 2020
d900cfd
some corrections
Jim-215-Fisher Dec 21, 2020
2a650ed
minor corrections
Jim-215-Fisher Dec 21, 2020
d4f701c
wrong place
Jim-215-Fisher Dec 21, 2020
2a495ab
Add files via upload
Jim-215-Fisher Dec 22, 2020
8e95e05
Add files via upload
Jim-215-Fisher Dec 22, 2020
3d8e3e6
Add files via upload
Jim-215-Fisher Dec 22, 2020
0629dbf
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Dec 22, 2020
b076c2d
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Dec 22, 2020
b58681c
chg. complex numbers with kinds
Jim-215-Fisher Dec 27, 2020
c2f1108
chn. complex number to kinds causes change in complex random number
Jim-215-Fisher Dec 27, 2020
be19e11
remove tab
Jim-215-Fisher Dec 27, 2020
ad6e40a
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Dec 29, 2020
6fceac9
Update Makefile.manual
Jim-215-Fisher Dec 29, 2020
f00cd15
Update Makefile.manual
Jim-215-Fisher Dec 29, 2020
afb881e
Update Makefile.manual
Jim-215-Fisher Dec 29, 2020
8abb168
Update CMakeLists.txt
Jim-215-Fisher Dec 29, 2020
a16faec
Merge pull request #2 from fortran-lang/master
Jim-215-Fisher Dec 29, 2020
157dba8
Update CMakeLists.txt
Jim-215-Fisher Dec 29, 2020
d7643cb
Update Makefile.manual
Jim-215-Fisher Dec 29, 2020
5651f5e
Update CMakeLists.txt
Jim-215-Fisher Dec 29, 2020
5afcba5
Update CMakeLists.txt
Jim-215-Fisher Dec 29, 2020
4cb0041
Update CMakeLists.txt
Jim-215-Fisher Dec 29, 2020
91c1ad4
Update Makefile.manual
Jim-215-Fisher Dec 29, 2020
aed0d77
Update CMakeLists.txt
Jim-215-Fisher Dec 31, 2020
4d7fb2d
Update Makefile.manual
Jim-215-Fisher Dec 31, 2020
20a3403
Update CMakeLists.txt
Jim-215-Fisher Dec 31, 2020
fce3d03
Update Makefile.manual
Jim-215-Fisher Dec 31, 2020
a39f5ef
Update Makefile.manual
Jim-215-Fisher Dec 31, 2020
deb318a
Update Makefile.manual
Jim-215-Fisher Dec 31, 2020
96c921b
Merge pull request #4 from Jim-215-Fisher/master
Jim-215-Fisher Dec 31, 2020
ea14a81
Update CMakeLists.txt
Jim-215-Fisher Dec 31, 2020
d791afe
Update Makefile.manual
Jim-215-Fisher Dec 31, 2020
8cbbb51
Delete test_distribution_uniform.f90
Jim-215-Fisher Dec 31, 2020
460fdd5
Update index.md
Jim-215-Fisher Dec 31, 2020
e678818
Update Makefile.manual
Jim-215-Fisher Jan 1, 2021
d25097f
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher Jan 3, 2021
800d94e
add proedure name in error message
Jim-215-Fisher Jan 18, 2021
c6c5fa7
final version
Jim-215-Fisher Jan 18, 2021
3a6f26f
Merge pull request #9 from fortran-lang/master
Jim-215-Fisher Jan 19, 2021
c379711
Delete Makefile.manual
Jim-215-Fisher Jan 21, 2021
a5735ea
Update CMakeLists.txt
Jim-215-Fisher Jan 21, 2021
bd66d42
Add files via upload
Jim-215-Fisher Jan 21, 2021
3e89cdc
Update Makefile.manual
Jim-215-Fisher Jan 21, 2021
a1543f2
Update Makefile.manual
Jim-215-Fisher Jan 21, 2021
c9e67e7
Merge pull request #12 from Jim-215-Fisher/master
Jim-215-Fisher Jan 21, 2021
6abd81c
Update CMakeLists.txt
Jim-215-Fisher Jan 21, 2021
af74dac
Update Makefile.manual
Jim-215-Fisher Jan 21, 2021
fbd5f52
Add files via upload
Jim-215-Fisher Jan 21, 2021
d9709df
Add files via upload
Jim-215-Fisher Jan 21, 2021
da7d277
Add files via upload
Jim-215-Fisher Jan 21, 2021
349d0eb
Merge pull request #14 from fortran-lang/master
Jim-215-Fisher Jan 21, 2021
ffdb937
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Jan 22, 2021
c7cf916
Update CMakeLists.txt
Jim-215-Fisher Jan 22, 2021
ba70104
Update CMakeLists.txt
Jim-215-Fisher Jan 22, 2021
e155e1e
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Feb 6, 2021
2e810fc
update PRNG module
Jim-215-Fisher Feb 6, 2021
0beff2a
Merge pull request #20 from fortran-lang/master
Jim-215-Fisher Feb 7, 2021
ce9c467
Update index.md
Jim-215-Fisher Feb 7, 2021
9691008
Delete CMakeLists.txt
Jim-215-Fisher Feb 7, 2021
1513e84
Delete Makefile.manual
Jim-215-Fisher Feb 7, 2021
5600315
Delete CMakeLists.txt
Jim-215-Fisher Feb 7, 2021
c74589e
Delete Makefile.manual
Jim-215-Fisher Feb 7, 2021
6bd7b2a
Delete stdlib_stats_distribution_PRNG.fypp
Jim-215-Fisher Feb 7, 2021
bc93073
Create CmakeLists.txt
Jim-215-Fisher Feb 7, 2021
652094a
Delete CmakeLists.txt
Jim-215-Fisher Feb 7, 2021
310c047
Create CMakeLists.txt
Jim-215-Fisher Feb 7, 2021
b026328
Create Makefile.manual
Jim-215-Fisher Feb 7, 2021
80b1cc7
Create CMakeLists.txt
Jim-215-Fisher Feb 7, 2021
48ba194
Create Makefile.manual
Jim-215-Fisher Feb 7, 2021
e9433cf
Delete index.md
Jim-215-Fisher Feb 7, 2021
baa9495
Create index.md
Jim-215-Fisher Feb 7, 2021
8040c3e
Delete Makefile.manual
Jim-215-Fisher Feb 7, 2021
0ebfbde
Create Makefile.manual
Jim-215-Fisher Feb 7, 2021
b0fe2c4
Update Makefile.manual
Jim-215-Fisher Feb 7, 2021
b148167
Delete Makefile.manual
Jim-215-Fisher Feb 7, 2021
bb7118e
Create Makefile.manual
Jim-215-Fisher Feb 7, 2021
b184825
Update Makefile.manual
Jim-215-Fisher Feb 7, 2021
a47ea79
Update Makefile.manual
Jim-215-Fisher Feb 7, 2021
0073be2
Merge pull request #21 from Jim-215-Fisher/master
Jim-215-Fisher Feb 7, 2021
f8e1f76
Update index.md
Jim-215-Fisher Feb 7, 2021
f40c023
Update index.md
Jim-215-Fisher Feb 7, 2021
63a015e
Update index.md
Jim-215-Fisher Feb 7, 2021
6c7a3c6
Update CMakeLists.txt
Jim-215-Fisher Feb 7, 2021
d39097c
Update Makefile.manual
Jim-215-Fisher Feb 7, 2021
e4a405a
Update CMakeLists.txt
Jim-215-Fisher Feb 7, 2021
03d5a81
Update Makefile.manual
Jim-215-Fisher Feb 7, 2021
cdfb497
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Feb 8, 2021
e62f241
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Feb 8, 2021
cf408bc
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Feb 8, 2021
376bdc1
Update Makefile.manual
Jim-215-Fisher Feb 8, 2021
b6e0c36
Merge branch 'fortran-lang:master' into master
Jim-215-Fisher May 22, 2021
9bebab0
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher Jul 30, 2021
af7e831
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher Jul 30, 2021
09a172c
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher Jul 30, 2021
a55a671
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Jul 30, 2021
5dbad35
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Jul 30, 2021
8b9d16d
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Jul 30, 2021
06174e4
Update src/tests/stats/test_distribution_uniform.f90
Jim-215-Fisher Jul 30, 2021
0a00a03
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher Jul 30, 2021
193a9c5
Update test_distribution_uniform.f90
Jim-215-Fisher Jul 30, 2021
93acc2c
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Jul 30, 2021
c2dac0e
Update Makefile.manual
Jim-215-Fisher Jul 30, 2021
231bd35
Delete Makefile.manual
Jim-215-Fisher Jul 30, 2021
b9091e0
Create Makefile.manual
Jim-215-Fisher Jul 30, 2021
8214d74
Update Makefile.manual
Jim-215-Fisher Jul 30, 2021
6e3aca5
Delete CMakeLists.txt
Jim-215-Fisher Jul 30, 2021
ed25e21
Delete Makefile.manual
Jim-215-Fisher Jul 30, 2021
cfbee66
Create CMakeLists.txt
Jim-215-Fisher Jul 30, 2021
58394f1
Create Makefile.manual
Jim-215-Fisher Jul 30, 2021
cc29ce8
Merge pull request #22 from fortran-lang/master
Jim-215-Fisher Jul 30, 2021
cd061f6
Delete test_distribution_uniform.f90
Jim-215-Fisher Jul 30, 2021
230c1c6
Add files via upload
Jim-215-Fisher Jul 30, 2021
635cc7b
Update index.md
Jim-215-Fisher Jul 30, 2021
50d04e2
Update CMakeLists.txt
Jim-215-Fisher Jul 30, 2021
8eac7f1
Update Makefile.manual
Jim-215-Fisher Jul 30, 2021
7327142
Update Makefile.manual
Jim-215-Fisher Jul 30, 2021
ad180de
Merge pull request #23 from fortran-lang/master
Jim-215-Fisher Jul 30, 2021
14a7e09
Update CMakeLists.txt
Jim-215-Fisher Jul 30, 2021
5c2e5da
Update Makefile.manual
Jim-215-Fisher Jul 30, 2021
ad23f64
Update common.fypp
Jim-215-Fisher Jul 31, 2021
d963f09
Update CMakeLists.txt
Jim-215-Fisher Jul 31, 2021
d5cba5b
Update Makefile.manual
Jim-215-Fisher Jul 31, 2021
669fc99
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Jul 31, 2021
464fa31
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Jul 31, 2021
bc8a053
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Jul 31, 2021
c70b920
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Jul 31, 2021
75a66b2
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
61718ab
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
9849dcd
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
5d33ba7
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
5cebe32
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
d2117de
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
615ac95
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
e728ae0
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
fecbedf
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher Aug 1, 2021
4b2152d
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
d21a17c
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
aaeb17a
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
51e234c
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
3611e59
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
922ad3c
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
1fa3094
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
bf126c0
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
d0f62b2
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
54bcd22
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
1fac091
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
a2a993d
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
c331d67
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
1152f04
Update test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
8186ead
Update test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
939fd1a
Update test_distribution_uniform.fypp
Jim-215-Fisher Aug 1, 2021
2469f52
Merge branch 'fortran-lang:master' into master
Jim-215-Fisher Aug 9, 2021
a4330cc
slightly changed format and some minor corrections
Aug 15, 2021
b8a96b5
Merge remote-tracking branch 'upstream/master'
Aug 21, 2021
6379458
test
Aug 22, 2021
3988da1
Merge remote-tracking branch 'upstream/master'
Aug 22, 2021
1c46c10
Spell checked and minor correction
Aug 22, 2021
d9dcbe0
Merge 'origin/master' into Distribution-Uniform
Aug 22, 2021
a2bf0ed
modify index.md, CMakeList.txt and Makefile.manual
Aug 22, 2021
7bdfc05
minor change
Aug 22, 2021
65ec424
Minor style change for consistency with most other stdlib modules
milancurcic Sep 19, 2021
bd6c97c
Merge remote-tracking branch 'upstream/master' into Distribution-Uniform
Sep 20, 2021
edf6ac8
public naming change and some corrections
Sep 21, 2021
916f69a
Merge remote-tracking branch 'upstream/master'
Sep 21, 2021
870fd3b
Merge branch 'master' into Distribution-Uniform
Sep 21, 2021
c57e7fc
naming change and some corrections
Sep 21, 2021
ae1c3f9
Add comments and change some function names
Sep 22, 2021
a9eee6b
correct FYPP comment format
Sep 22, 2021
a904337
changed Version to version:, such that ford considers it as meta-info
jvdp1 Oct 2, 2021
884623b
update all specs links
jvdp1 Oct 2, 2021
a435b04
correct issue with syntax of pdf_uniform
jvdp1 Oct 2, 2021
b877660
update titles of specs of the different stdlib_stats_distribution
jvdp1 Oct 2, 2021
7a650f1
Merge pull request #25 from jvdp1/jim_uni
Jim-215-Fisher Oct 3, 2021
e11454d
Merge remote-tracking branch 'upstream/master' into Distribution-Uniform
Oct 3, 2021
b13a48e
remove uniform files
Oct 4, 2021
cc4d3f2
Merge remote-tracking branch 'upstream/master'
Oct 4, 2021
3bc615b
modify CMakeLists, Makefile, and index
Oct 4, 2021
22a6023
change PRNG to random
Oct 4, 2021
39e991b
change PRNG in test to random
Oct 4, 2021
227e520
spell checked
Oct 4, 2021
bcd876c
spell checked
Oct 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/specs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This is and index/directory of the specifications (specs) for each new module/fe
- [sorting](./stdlib_sorting.html) - Sorting of rank one arrays
- [stats](./stdlib_stats.html) - Descriptive Statistics
- [stats_distribution_PRNG](./stdlib_stats_distribution_PRNG.html) - Probability Distributions random number generator
- [stats_distribution_uniform](./stdlib_stats_distribution_uniform.html) - Uniform probability distribution
- [string\_type](./stdlib_string_type.html) - Basic string support
- [strings](./stdlib_strings.html) - String handling and manipulation routines
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings
Expand Down
379 changes: 379 additions & 0 deletions doc/specs/stdlib_stats_distribution_uniform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,379 @@
---
title: stats_distribution
milancurcic marked this conversation as resolved.
Show resolved Hide resolved
---

# Statistical Distributions -- Uniform Distribution Module

[TOC]

## `shuffle` - Using Fisher-Yates algorithm to generate a random permutation of a list

### Status

Experimental

### Description

Applying Fisher-Yates algorithm to generate an unbiased permutation for any list of intrinsic numerical data types.

### Syntax

`result = [[stdlib_stats_distribution_uniform(module):shuffle(interface)]]( list )`

Jim-215-Fisher marked this conversation as resolved.
Show resolved Hide resolved
### Class

Function.

### Arguments

`list`: argument has `intent(in)` and is a rank one array of `integer`, `real`, or `complex` type.

### Return value

Return a randomized rank one array of the input type.

### Example

```fortran
program demo_shuffle
use stdlib_stats_distribution_PRNG, only : random_seed
use stdlib_stats_distribution_uniform, only : shuffle
implicit none
integer :: seed_put, seed_get, i
real :: x(10)
integer :: n(10)
complex :: z(10)

do i=1, 10
n(i) = i
x(i) = real(i)
z(i) = cmplx(real(i), real(i))
end do
seed_put = 32165498
call random_seed(seed_put, seed_get) ! set and get current value of seed
print *, shuffle(n) ! get randomized n

!10 6 9 2 8 1 3 5 7 4

print *, shuffle(x) ! get randomized x

!5.0 10.0 9.0 4.0 3.0 8.0 2.0 1.0 7.0 6.0

print *, shuffle(z) ! get randomized z

!(8.0, 8.0) (7.0, 7.0) (4.0, 4.0) (1.0, 1.0) (5.0, 5.0)
!(9.0, 9.0) (6.0, 6.0) (3.0, 3.0) (2.0, 2.0) (10.0, 10.0)

end program demo_shuffle
```

## `rvs_uniform` - uniform distribution random variates

### Status

Experimental

### Description

Without argument the function returns a scalar standard uniformly distributed variate U(0,1) of `real` type with single precision on [0,1].

With single argument `scale` of `integer` type the function returns a scalar uniformly distributed variate of `integer` type on [0,scale]. This is the standard Rectangular distribution.

With single argument `scale` of `real` or `complex` type the function returns a scalar uniformly distributed variate of `real` or `complex` type on [0, scale].

With double arguments `loc` and `scale` the function returns a scalar uniformly distributed random variates of `integer`, `real` or `complex` type on [loc, loc + scale] dependent of input type.

With triple arguments `loc`, `scale` and `array_size` the function returns a rank one array of uniformly distributed variates of `integer`, `real` or `complex` type with an array size of `array_size`.

For `complex` type, the real part and imaginary part are independent of each other.

### Syntax

`result = [[stdlib_stats_distribution_uniform(module):rvs_uniform(interface)]]([[loc,] scale] [[[,array_size]]])`

### Class

Elemental function (without the third argument).

Jim-215-Fisher marked this conversation as resolved.
Show resolved Hide resolved
### Arguments

`loc`: optional argument has `intent(in)` and is a scalar of type `integer`, `real` or `complex`.
Jim-215-Fisher marked this conversation as resolved.
Show resolved Hide resolved

`scale`: optional argument has `intent(in)` and is a scalar of type `integer`, `real` or `complex`.

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

`loc` and `scale` must have the same type and kind when both are present.

### Return value

The result is a scalar or a rank one array, with size of `array_size`, of type `integer`, `real` or `complex` depending on the input type.

### Example

```fortran
program demo_uniform_rvs
use stdlib_stats_distribution_PRNG, only:random_seed
use stdlib_stats_distribution_uniform, only:uni=> rvs_uniform
jvdp1 marked this conversation as resolved.
Show resolved Hide resolved

implicit none
complex :: loc, scale
real :: a(3,4,5), b(3,4,5)
integer :: seed_put, seed_get

seed_put = 1234567
call random_seed(seed_put, seed_get)

print *, uni( ) !real standard uniform random variate in [0., 1.]
! 0.161520019

print *, uni(3.0) !an uniform random variate in [0., 3.]
! 1.65974522

print *, uni(-0.5, 1.0) !an uniform random variate in [-0.5, 0.5]
! 0.486900032

print *, uni(-1.0,2.0,10)
!an array of 10 uniform random variates in [-1., 1.]

!0.884182811 -0.771520197 0.560377002 0.709313750 -7.12267756E-02
!-0.431066573 0.497536063 -0.396331906 -0.325983286 0.137686729

print *, uni(20) !a random integer variate in [0, 20]
! 17

print *, uni(5,13) !a random integer variate in [5, 18]
! 15

print *, uni(3,19,10) !an array of 10 integer variates in [3,22]

!7 16 16 12 9 21 19 4 3 19

loc = (-0.5, -0.5)
scale = (1.0, 1.0)

print *, uni(scale) !a complex uniform random variate in unit square

!(0.139202669, 0.361759573)

print *, uni(loc,scale)
!a complex uniform random variate in [(-0.5, -0.5), (0.5, 0.5)]

!(0.296536088,-0.143987954)

print *, uni(loc, scale, 10)
!an array of 10 complex uniform random variate in [(-0.5, -0.5), (0.5, 0.5)]

!(-0.302334785,-0.401923567) (0.281620383,9.534919262E-02)
! (-0.374348879,0.457528770) (0.442990601,-0.240510434)
! (-0.421572685,0.279313922) (-0.182090610,5.901372433E-02)
! (-7.864198089E-02,0.378484428) (-0.423258364,-0.201292425)
! (0.193327367,-0.353985727) (-0.397661150,0.355926156)

a(:,:,:) = -0.5
b(:,:,:) = 1.0

print *, uni(a,b)
!a rank 3 array of random variates in [-0.5,0.5]

! -0.249188632 -0.199248433 -0.389813602 2.88307667E-03 0.238479793,
! 0.264856219 -0.205177426 -0.480921626 0.131218433 0.252170086,
! -0.303151041 -8.89462233E-02 -0.377370685 0.341802299 0.323204756,
! 0.358679056 -0.138909757 0.384329498 -0.109372199 0.132353067,
! 0.494320452 0.419343710 -0.103044361 0.461389005 0.403132677
! 0.121850729 0.403839290 -0.349389791 0.490482628 0.156600773
! 8.46788883E-02 -0.483680278 0.388107836 0.119698405 0.154214382
! 0.153113484 0.236523747 0.155937552 -0.135760903 0.219589531
! 0.394639254 6.30156994E-02 -0.342692465 -0.444846451 -0.215700030
! 0.204189956 -0.208748132 0.355063021 8.98272395E-02 -0.237928331
! 2.98077464E-02 -0.485149682 -8.06870461E-02 -0.372713923
! -0.178335011 0.283877611 -2.13934183E-02 -9.21690464E-03
! 4.56320047E-02 0.220112979

end program demo_uniform_rvs
```

## `pdf_uniform` - Uniform probability density function

### Status

Experimental

### Description

The probability density function of the uniform distribution.

f(x) = 1 / (scale + 1); for discrete uniform distribution.

f(x) = 1 / scale; for continuous uniform distribution.

f(x) = 1 / (scale%re * scale%im); for complex uniform distribution.

### Syntax

`result = [[stdlib_stats_distribution_uniform(module):uniform_distribution_pdf(interface)]](x, loc, scale)`

jvdp1 marked this conversation as resolved.
Show resolved Hide resolved
### Class

Elemental function.

### Arguments

`x`: has `intent(in)` and is a scalar of type `integer`, `real` or `complex`.

`loc`: has `intent(in)` and is a scalar of type `integer`, `real` or `complex`.

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

All three arguments must have the same type and kind.

### Return value

The result is a scalar or an array, with a shape conformable to arguments, of type `real`.

### Example

```fortran
program demo_uniform_pdf
use stdlib_stats_distribution_PRNG, only : random_seed
use stdlib_stats_distribution_uniform, only : uni_pdf => pdf_uniform, &
uni => rvs_uniform

implicit none
complex :: loc, scale
real :: a(3,4,5), b(3,4,5), x(3,4,5)
integer :: seed_put, seed_get

seed_put = 1234567
call random_seed(seed_put, seed_get)

print *, uni_pdf(3, 2, 10) !probability density at 3 in range [2, 10]

! 9.09090936E-02

print *, uni_pdf(0.5,0.0,1.0) !a probability density at 0.5 in [0., 1.]

! 1.00000000


print *, uni_pdf(0.7,-1.0,2.0) !a probability density at 0.7 in [-1., 1.]

! 0.500000000

a(:,:,:) = 0.0
b(:,:,:) = 2.0
x = reshape(uni(0.,2.,60),[3,4,5])! uniform random variates array in [0., 2.]
print *, uni_pdf(x, a, b) ! probability density array in [0., 2.]

! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000
! 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000 0.500000000

loc = (-0.5,-0.5)
scale = (1.0,1.0)
print *, uni_pdf((-0.1,0.2), loc, scale)
! joint probability density at (-0.1,0.2) in [(-0.5, -0.5), (0.5, 0.5)]

! 1.00000000
end program demo_uniform_pdf

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

```

## `cdf_uniform` - Uniform cumulative distribution function

### Status

Experimental

### Description

Cumulative distribution function of the uniform distribution

F(x) = (x - loc + 1) / (scale + 1); for discrete uniform distribution.

F(x) = (x - loc) / scale; for continuous uniform distribution.

F(x) = (x%re - loc%re)(x%im - loc%im) / (scale%re * scale%im); for complex uniform distribution.

### Syntax

`result = [[stdlib_stats_distribution_uniform(module):cdf_uniform(interface)]](x, loc, scale)`

### Class

Elemental function.

jvdp1 marked this conversation as resolved.
Show resolved Hide resolved
### Arguments

`x`: has `intent(in)` and is a scalar of type `integer`, `real` or `complex`.

`loc`: has `intent(in)` and is a scalar of type `integer`, `real` or `complex`.

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

All three arguments must have the same type and kind.

### Return value

The result is a scalar or an array, with a shape conformable to arguments, of type `real`.

### Example

```fortran
program demo_uniform_cdf
use stdlib_stats_distribution_PRNG, only : random_seed
use stdlib_stats_distribution_uniform, only : uni_cdf => cdf_uniform, &
uni => rvs_uniform

implicit none
real :: x(3,4,5), a(3,4,5), b(3,4,5)
complex :: loc, scale
integer :: seed_put, seed_get

seed_put = 1234567
call random_seed(seed_put, seed_get)

print *, uni_cdf(0.5,0.,1.) ! a cumulative at 0.5 in [0., 1.]

!0.500000000

print *, uni_cdf(0.7,-1.0,2.0) ! a cumulative at 0.7 in [-1.0, 1.0]

! 0.850000024

print *, uni_cdf(6, 2, 10) ! a cumulative at 6 in [2, 10]

! 0.454545468

a(:,:,:) = -1.0
b(:,:,:) = 2.0
x = reshape(uni(-1.0,2.0,60),[3,4,5]) ! uniform random variates array
print *, uni_cdf(x,a,b) ! cumulative array in [-1.0, 1.0]

!0.161520004 0.553248405 0.986900032 0.942091405 0.114239901 0.780188501
! 0.854656875 0.464386612 0.284466714 0.748768032 0.301834047 0.337008357
!0.568843365 0.596165061 0.180993259 0.614166319 0.214835495 7.98164606E-02
!0.641274095 0.607101977 0.701139212 0.230517209 1.97925568E-02 0.857982159
!0.712761045 0.139202654 0.361759573 0.796536088 0.356012046 0.197665215
!9.80764329E-02 0.781620383 0.595349193 0.125651121 0.957528770 0.942990601
!0.259489566 7.84273148E-02 0.779313922 0.317909390 0.559013724 0.421358019
!0.878484428 7.67416358E-02 0.298707575 0.693327367 0.146014273 0.102338850
!0.855926156 0.250811368 0.300751567 0.110186398 0.502883077 0.738479793
!0.764856219 0.294822574 1.90783739E-02 0.631218433 0.752170086 0.196848959

loc = (0., 0.)
scale=(2., 1.)
print *, uni_cdf((1.2,0.5), loc, scale)
! joint cumulative distribution at (1.2,0.5) in [(0.,0.), (2.,1.)]

! 0.300000012
end program demo_uniform_cdf

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

```
Loading