-
Notifications
You must be signed in to change notification settings - Fork 188
Probability Distribution and Statistical Functions -- Uniform Distribution Module #272
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
Merged
jvdp1
merged 193 commits into
fortran-lang:master
from
Jim-215-Fisher:Distribution-Uniform
Oct 6, 2021
Merged
Changes from all commits
Commits
Show all changes
193 commits
Select commit
Hold shift + click to select a range
edf8e54
change in Makefile.manual
Jim-215-Fisher 322a3a8
Add files via upload
Jim-215-Fisher 4b336de
initial commit
Jim-215-Fisher 1664d42
initial commit
Jim-215-Fisher dbb7de7
Add files via upload
Jim-215-Fisher d3214fc
correct file
Jim-215-Fisher 7d30492
convert % complex representation to real() and aimag() representation
Jim-215-Fisher 0d3b59f
Convert complex representation
Jim-215-Fisher 3987d62
Convert complex number representtion
Jim-215-Fisher 98e3d48
remove tab
Jim-215-Fisher b714194
remove tab
Jim-215-Fisher 49f9d89
minor change
Jim-215-Fisher d900cfd
some corrections
Jim-215-Fisher 2a650ed
minor corrections
Jim-215-Fisher d4f701c
wrong place
Jim-215-Fisher 2a495ab
Add files via upload
Jim-215-Fisher 8e95e05
Add files via upload
Jim-215-Fisher 3d8e3e6
Add files via upload
Jim-215-Fisher 0629dbf
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher b076c2d
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher b58681c
chg. complex numbers with kinds
Jim-215-Fisher c2f1108
chn. complex number to kinds causes change in complex random number
Jim-215-Fisher be19e11
remove tab
Jim-215-Fisher ad6e40a
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher 6fceac9
Update Makefile.manual
Jim-215-Fisher f00cd15
Update Makefile.manual
Jim-215-Fisher afb881e
Update Makefile.manual
Jim-215-Fisher 8abb168
Update CMakeLists.txt
Jim-215-Fisher a16faec
Merge pull request #2 from fortran-lang/master
Jim-215-Fisher 157dba8
Update CMakeLists.txt
Jim-215-Fisher d7643cb
Update Makefile.manual
Jim-215-Fisher 5651f5e
Update CMakeLists.txt
Jim-215-Fisher 5afcba5
Update CMakeLists.txt
Jim-215-Fisher 4cb0041
Update CMakeLists.txt
Jim-215-Fisher 91c1ad4
Update Makefile.manual
Jim-215-Fisher aed0d77
Update CMakeLists.txt
Jim-215-Fisher 4d7fb2d
Update Makefile.manual
Jim-215-Fisher 20a3403
Update CMakeLists.txt
Jim-215-Fisher fce3d03
Update Makefile.manual
Jim-215-Fisher a39f5ef
Update Makefile.manual
Jim-215-Fisher deb318a
Update Makefile.manual
Jim-215-Fisher 96c921b
Merge pull request #4 from Jim-215-Fisher/master
Jim-215-Fisher ea14a81
Update CMakeLists.txt
Jim-215-Fisher d791afe
Update Makefile.manual
Jim-215-Fisher 8cbbb51
Delete test_distribution_uniform.f90
Jim-215-Fisher 460fdd5
Update index.md
Jim-215-Fisher e678818
Update Makefile.manual
Jim-215-Fisher d25097f
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher 800d94e
add proedure name in error message
Jim-215-Fisher c6c5fa7
final version
Jim-215-Fisher 3a6f26f
Merge pull request #9 from fortran-lang/master
Jim-215-Fisher c379711
Delete Makefile.manual
Jim-215-Fisher a5735ea
Update CMakeLists.txt
Jim-215-Fisher bd66d42
Add files via upload
Jim-215-Fisher 3e89cdc
Update Makefile.manual
Jim-215-Fisher a1543f2
Update Makefile.manual
Jim-215-Fisher c9e67e7
Merge pull request #12 from Jim-215-Fisher/master
Jim-215-Fisher 6abd81c
Update CMakeLists.txt
Jim-215-Fisher af74dac
Update Makefile.manual
Jim-215-Fisher fbd5f52
Add files via upload
Jim-215-Fisher d9709df
Add files via upload
Jim-215-Fisher da7d277
Add files via upload
Jim-215-Fisher 349d0eb
Merge pull request #14 from fortran-lang/master
Jim-215-Fisher ffdb937
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher c7cf916
Update CMakeLists.txt
Jim-215-Fisher ba70104
Update CMakeLists.txt
Jim-215-Fisher e155e1e
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 2e810fc
update PRNG module
Jim-215-Fisher 0beff2a
Merge pull request #20 from fortran-lang/master
Jim-215-Fisher ce9c467
Update index.md
Jim-215-Fisher 9691008
Delete CMakeLists.txt
Jim-215-Fisher 1513e84
Delete Makefile.manual
Jim-215-Fisher 5600315
Delete CMakeLists.txt
Jim-215-Fisher c74589e
Delete Makefile.manual
Jim-215-Fisher 6bd7b2a
Delete stdlib_stats_distribution_PRNG.fypp
Jim-215-Fisher bc93073
Create CmakeLists.txt
Jim-215-Fisher 652094a
Delete CmakeLists.txt
Jim-215-Fisher 310c047
Create CMakeLists.txt
Jim-215-Fisher b026328
Create Makefile.manual
Jim-215-Fisher 80b1cc7
Create CMakeLists.txt
Jim-215-Fisher 48ba194
Create Makefile.manual
Jim-215-Fisher e9433cf
Delete index.md
Jim-215-Fisher baa9495
Create index.md
Jim-215-Fisher 8040c3e
Delete Makefile.manual
Jim-215-Fisher 0ebfbde
Create Makefile.manual
Jim-215-Fisher b0fe2c4
Update Makefile.manual
Jim-215-Fisher b148167
Delete Makefile.manual
Jim-215-Fisher bb7118e
Create Makefile.manual
Jim-215-Fisher b184825
Update Makefile.manual
Jim-215-Fisher a47ea79
Update Makefile.manual
Jim-215-Fisher 0073be2
Merge pull request #21 from Jim-215-Fisher/master
Jim-215-Fisher f8e1f76
Update index.md
Jim-215-Fisher f40c023
Update index.md
Jim-215-Fisher 63a015e
Update index.md
Jim-215-Fisher 6c7a3c6
Update CMakeLists.txt
Jim-215-Fisher d39097c
Update Makefile.manual
Jim-215-Fisher e4a405a
Update CMakeLists.txt
Jim-215-Fisher 03d5a81
Update Makefile.manual
Jim-215-Fisher cdfb497
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher e62f241
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher cf408bc
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher 376bdc1
Update Makefile.manual
Jim-215-Fisher b6e0c36
Merge branch 'fortran-lang:master' into master
Jim-215-Fisher 9bebab0
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher af7e831
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher 09a172c
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher a55a671
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher 5dbad35
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 8b9d16d
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 06174e4
Update src/tests/stats/test_distribution_uniform.f90
Jim-215-Fisher 0a00a03
Update stdlib_stats_distribution_uniform.md
Jim-215-Fisher 193a9c5
Update test_distribution_uniform.f90
Jim-215-Fisher 93acc2c
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher c2dac0e
Update Makefile.manual
Jim-215-Fisher 231bd35
Delete Makefile.manual
Jim-215-Fisher b9091e0
Create Makefile.manual
Jim-215-Fisher 8214d74
Update Makefile.manual
Jim-215-Fisher 6e3aca5
Delete CMakeLists.txt
Jim-215-Fisher ed25e21
Delete Makefile.manual
Jim-215-Fisher cfbee66
Create CMakeLists.txt
Jim-215-Fisher 58394f1
Create Makefile.manual
Jim-215-Fisher cc29ce8
Merge pull request #22 from fortran-lang/master
Jim-215-Fisher cd061f6
Delete test_distribution_uniform.f90
Jim-215-Fisher 230c1c6
Add files via upload
Jim-215-Fisher 635cc7b
Update index.md
Jim-215-Fisher 50d04e2
Update CMakeLists.txt
Jim-215-Fisher 8eac7f1
Update Makefile.manual
Jim-215-Fisher 7327142
Update Makefile.manual
Jim-215-Fisher ad180de
Merge pull request #23 from fortran-lang/master
Jim-215-Fisher 14a7e09
Update CMakeLists.txt
Jim-215-Fisher 5c2e5da
Update Makefile.manual
Jim-215-Fisher ad23f64
Update common.fypp
Jim-215-Fisher d963f09
Update CMakeLists.txt
Jim-215-Fisher d5cba5b
Update Makefile.manual
Jim-215-Fisher 669fc99
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher 464fa31
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher bc8a053
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher c70b920
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher 75a66b2
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 61718ab
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 9849dcd
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 5d33ba7
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 5cebe32
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher d2117de
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 615ac95
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher e728ae0
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher fecbedf
Update doc/specs/stdlib_stats_distribution_uniform.md
Jim-215-Fisher 4b2152d
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher d21a17c
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher aaeb17a
Update src/stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 51e234c
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher 3611e59
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher 922ad3c
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher 1fa3094
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher bf126c0
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher d0f62b2
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher 54bcd22
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher 1fac091
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher a2a993d
Update src/tests/stats/test_distribution_uniform.fypp
Jim-215-Fisher c331d67
Update stdlib_stats_distribution_uniform.fypp
Jim-215-Fisher 1152f04
Update test_distribution_uniform.fypp
Jim-215-Fisher 8186ead
Update test_distribution_uniform.fypp
Jim-215-Fisher 939fd1a
Update test_distribution_uniform.fypp
Jim-215-Fisher 2469f52
Merge branch 'fortran-lang:master' into master
Jim-215-Fisher a4330cc
slightly changed format and some minor corrections
b8a96b5
Merge remote-tracking branch 'upstream/master'
6379458
test
3988da1
Merge remote-tracking branch 'upstream/master'
1c46c10
Spell checked and minor correction
d9dcbe0
Merge 'origin/master' into Distribution-Uniform
a2bf0ed
modify index.md, CMakeList.txt and Makefile.manual
7bdfc05
minor change
65ec424
Minor style change for consistency with most other stdlib modules
milancurcic bd6c97c
Merge remote-tracking branch 'upstream/master' into Distribution-Uniform
edf6ac8
public naming change and some corrections
916f69a
Merge remote-tracking branch 'upstream/master'
870fd3b
Merge branch 'master' into Distribution-Uniform
c57e7fc
naming change and some corrections
ae1c3f9
Add comments and change some function names
a9eee6b
correct FYPP comment format
a904337
changed Version to version:, such that ford considers it as meta-info
jvdp1 884623b
update all specs links
jvdp1 a435b04
correct issue with syntax of pdf_uniform
jvdp1 b877660
update titles of specs of the different stdlib_stats_distribution
jvdp1 7a650f1
Merge pull request #25 from jvdp1/jim_uni
Jim-215-Fisher e11454d
Merge remote-tracking branch 'upstream/master' into Distribution-Uniform
b13a48e
remove uniform files
cc4d3f2
Merge remote-tracking branch 'upstream/master'
3bc615b
modify CMakeLists, Makefile, and index
22a6023
change PRNG to random
39e991b
change PRNG in test to random
227e520
spell checked
bcd876c
spell checked
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,379 @@ | ||||
--- | ||||
title: stats_distribution_uniform | ||||
--- | ||||
|
||||
# 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 )` | ||||
|
||||
### 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):pdf_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_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 | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.