Module for basic sample statistics.
Ranks all samples such that the smallest value obtains rank 1 and the largest rank n. Handles tied ranks and assigns average rank to tied elements within one group of tied elements.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x(:) |
x array |
||
| real(kind=wp), | intent(out), | allocatable | :: | ranks(:) |
ranks of x |
Subroutine for creating k ~equal-sized samples of a rank-1 array. The array indices are shuffled using the Fisher–Yates algorithm. Then, k logical masks are constructed. In each mask, the indices belonging to one of the k folds (not part of the sample) are set to .false. and the remaining indices are set to .true., making the masks directly suitable for k-fold cross-validation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i4), | intent(in) | :: | m |
size of population (array) |
||
| integer(kind=i4), | intent(in) | :: | k |
number of subsample sets |
||
| logical, | intent(out) | :: | mask(m,k) |
index mask for sampled data |
Subroutine for sampling a rank 1 array. It shuffles indeces using the forward Fisher-Yates algorithm (as needed given n), then generates an index mask from it. The mask can simply be applied using the pack intrinsic function: new_array = pack (old_array, mask)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i4), | intent(in) | :: | m |
size of population (array) |
||
| integer(kind=i4), | intent(in) | :: | n |
size of sample |
||
| logical, | intent(out) | :: | mask(m) |
index mask for sampled data |
Subroutine for sampling a rank 1 array using Poisson sampling (subjecting individual elements independently to Bernoulli experiments), then generates an index mask for sampling. The mask can simply be applied using the pack intrinsic function: new_array = pack (old_array, mask)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i4), | intent(in) | :: | m |
size of population (array) |
||
| real(kind=wp), | intent(in) | :: | p |
inclusion probability |
||
| logical, | intent(out) | :: | mask(m) |
index mask for sampled data |
Sort real array in ascending (mode=1) or descending (mode=2) order. Preserves the input array. Outputs sorted array and index mapping.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | a_in(n) |
input array (unchanged) |
||
| integer(kind=i4), | intent(in) | :: | n |
number of elements |
||
| integer(kind=i4), | intent(in) | :: | mode |
1=ascending, 2=descending |
||
| integer(kind=i4), | intent(in) | :: | idx_in(n) |
initial index mapping |
||
| real(kind=wp), | intent(out) | :: | a_out(n) |
sorted output array |
||
| integer(kind=i4), | intent(out) | :: | idx_out(n) |
updated index mapping |