FSML interface module.
The one-way ANOVA (Analysis of Variance) tests whether three or more population means are equal.
The null hypothesis and alternative hypothesis are defined as: : , and : At least one differs from the others.
The data is passed to the procedure as a rank-2 array x
, where each column is a group of observations.
The procedure partitions then the total variability in the data ( ) into
variability between groups ( ; variability explained by groups ), and
variability within groups ( ; unexplained or residual variability ), so that
The F-statistic (f
) is the ratio of the mean sum of squares between groups
to the mean sum of squares within groups:
where is the number of groups, is the total number of observations,
is the sum of squares between groups, and
is the sum of squares within groups.
The degrees of freedom are between groups (df_b
)
and within groups (df_w
).
The resulting p-value (p
) is computed from the F-distribution:
It is computed with the elemental procedure f_dst_f_cdf_core
.
The ANOVA makes the assumptions that a) the groups are independent, b) the observations within each group are normally distributed, and c) The variances within groups are equal.
Impure wrapper procedure for s_tst_anova_1w_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:,:) |
2D array, each column is a group |
||
real(kind=wp), | intent(out) | :: | f |
F-statistic |
||
real(kind=wp), | intent(out) | :: | df_b |
degrees of freedom between groups |
||
real(kind=wp), | intent(out) | :: | df_w |
degrees of freedom within groups |
||
real(kind=wp), | intent(out) | :: | p |
p-value from F distribution |
Cumulative distribution function for the chi-squared distribution.
Impure wrapper function for f_dst_chi2_cdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
real(kind=wp), | intent(in), | optional | :: | scale |
scale parameter |
|
character(len=*), | intent(in), | optional | :: | tail |
tail options |
resulting CDF value
Probability density function for the chi-squared distribution.
Uses intrinsic exp and gamma function.
where = degrees of freedom (df
) and is the gamma function.
Impure wrapper function for f_dst_chi2_pdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
real(kind=wp), | intent(in), | optional | :: | scale |
scale parameter |
resulting PDF value
Percent point function/quantile function for the chi-squared distribution. Uses the bisection method for numerical inversion of the CDF.
Impure wrapper function for f_dst_chi2_ppf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | p |
probability between 0.0 and 1.0 |
||
real(kind=wp), | intent(in) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
real(kind=wp), | intent(in), | optional | :: | scale |
scale parameter |
sample position
Computes the population or sample covariance (depending on passed arguments).
where is the size of (or number of observations in) vectors x
and y
,
and are individual elements in x
and y
,
(ddof
) is a degrees of freedom adjustment
(ddof = 0.0
for population variance, ddof = 1.0
for sample variance), and
and are the arithmetic means of x
and y
.
Vectors x
and y
must be the same size.
Impure wrapper function for f_sts_cov_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in) | :: | y(:) |
y vector (assumed size array) |
||
real(kind=wp), | intent(in), | optional | :: | ddof |
delta degrees of freedom |
covariance
Cumulative distribution function for exponential distribution.
Impure wrapper function for f_dst_exp_cdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in), | optional | :: | lambda |
lambda parameter, beta(scale) = 1/lambda = mu/mean |
|
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
character(len=*), | intent(in), | optional | :: | tail |
tail options |
returned probability integral
Probability density function for exponential distribution. Uses intrinsic exp function.
Impure wrapper function for f_dst_exp_pdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in), | optional | :: | lambda |
lambda parameter, beta(scale) = 1/lambda = mu/mean |
|
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
Percent point function/quantile function for exponential distribution.
Procedure uses bisection method. p
should be between 0.0 and 1.0.
Impure wrapper function for f_dst_exp_ppf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | p |
probability between 0.0 - 1.0 |
||
real(kind=wp), | intent(in), | optional | :: | lambda |
lambda parameter, beta(scale) = 1/lambda = mu/mean |
|
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
sample position
Cumulative density function for the F distribution.
Impure wrapper function for f_dst_f_cdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | d1 |
numerator degrees of freedom |
||
real(kind=wp), | intent(in) | :: | d2 |
denominator degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
real(kind=wp), | intent(in), | optional | :: | scale |
scale parameter |
|
character(len=*), | intent(in), | optional | :: | tail |
tail option |
output probability
Probability density function for the F distribution. where = numerator degrees of freedom, = denominator degrees of freedom and is the complete beta function. (Uses intrinsic gamma function for beta.)
The F distribution is the distribution of , where and are are random variables with chi-square distributions with and degrees of freedom, respectively.
Impure wrapper function for f_dst_f_pdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | d1 |
numerator degrees of freedom |
||
real(kind=wp), | intent(in) | :: | d2 |
denominator degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
real(kind=wp), | intent(in), | optional | :: | scale |
scale parameter |
Percent point function / quantile function for the F distribution. Uses the bisection method to numerically invert the CDF.
Impure wrapper function for f_dst_f_ppf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | p |
probability (0.0 < p < 1.0) |
||
real(kind=wp), | intent(in) | :: | d1 |
numerator degrees of freedom |
||
real(kind=wp), | intent(in) | :: | d2 |
denominator degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
real(kind=wp), | intent(in), | optional | :: | scale |
scale parameter |
Cumulative distribution function for gamma distribution.
Impure wrapper function for f_dst_gamma_cdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in), | optional | :: | alpha |
shape parameter |
|
real(kind=wp), | intent(in), | optional | :: | beta |
scale parameter |
|
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
character(len=*), | intent(in), | optional | :: | tail |
tail options |
returned probability integral
Probability density function for gamma distribution. Uses intrinsic exp function.
Impure wrapper function for f_dst_gamma_pdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in), | optional | :: | alpha |
shape parameter |
|
real(kind=wp), | intent(in), | optional | :: | beta |
scale parameter |
|
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
Percent point function/quantile function for gamma distribution.
Procedure uses bisection method. p
should be between 0.0 and 1.0.
Impure wrapper function for f_dst_gamma_ppf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | p |
probability between 0.0 - 1.0 |
||
real(kind=wp), | intent(in), | optional | :: | alpha |
shape parameter |
|
real(kind=wp), | intent(in), | optional | :: | beta |
scale parameter |
|
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
sample position
Cumulative distribution function for generalised pareto distribution.
Impure wrapper function for f_dst_gpd_cdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | xi |
distribution shape parameter |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (must be positive) |
|
character(len=*), | intent(in), | optional | :: | tail |
tail options |
returned probability integral
Probability density function for generalised pareto distribution. where is a shape parameter (xi), is the scale parameter (sigma), (mu) is the location (not mean).
Impure wrapper function for f_dst_gpd_pdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | xi |
distribution shape parameter |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (must be positive) |
Percent point function/quantile function for generalised pareto distribution.
Procedure uses bisection method. p
must be between 0.0 and 1.0.
Impure wrapper function for f_dst_gpd_ppf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | p |
probability between 0.0 - 1.0 |
||
real(kind=wp), | intent(in), | optional | :: | xi |
distribution shape parameter |
|
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (must be positive) |
sample position
The Kruskal-Wallis H-test is used to determine whether samples originate from the same distribution without assuming normality. It is therefore considered a nonparametric alternative to the one-way ANOVA (Analysis of Variance).
The null hypothesis and alternative hypothesis are defined as: : The populations have the same distribution (medians are equal), and : At least one population differs from the others.
The data is passed to the procedure as a rank-2 array x
, where each column is a group of observations.
All values are ranked across the entire dataset, with tied values assigned the average rank.
The Kruskal-Wallis H-statistic (h
) is computed as:
where:
- is the total number of observations,
- is the number of groups,
- is the number of observations in group , and
- is the sum of ranks in group .
The degrees of freedom are:
and returned as df
.
The p-value (p
) is computed from the chi-squared distribution:
It is computed using the elemental procedure f_dst_chi2_cdf_core
.
The Kruskal-Wallis test assumes that: a) all groups are independent, b) the response variable is ordinal or continuous, c) the group distributions have the same shape, and d) observations are independent both within and between groups.
Impure wrapper procedure for s_tst_kruskalwallis_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:,:) |
2D array, each column is a group |
||
real(kind=wp), | intent(out) | :: | h |
Kruskal-Wallis H-statistic |
||
real(kind=wp), | intent(out) | :: | df |
degrees of freedom (k - 1) |
||
real(kind=wp), | intent(out) | :: | p |
p-value from chi-squared distribution |
Computes arithmetic mean.
where is the size of (or number of observations in) vector x
,
are individual elements in x
, and
is the arithmetic mean of x
.
Impure wrapper function for f_sts_mean_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
arithmetic mean
Cumulative distribution function for normal distribution.
The location parameter (mu
) is an optional argument and will default to 0.0 if not passed.
The scale parameter (sigma
) is an optional argument. If passed, it must be non-zero positive.
It will default to 1.0 if not passed.
The tail option (tail
) is an optional argument. If passed, it must be one of the following:
"left", "right", "two", or "confidence". If not passed, it will default to "left".
Impure wrapper function for f_dst_norm_cdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location (mean) |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (standard deviation) |
|
character(len=*), | intent(in), | optional | :: | tail |
tail options |
returned probability integral
Probability density function for normal distribution.
The location parameter (mu
) is an optional argument and will default to 0.0 if not passed.
The scale parameter (sigma
) is an optional argument. If passed, it must be non-zero positive.
It will default to 1.0 if not passed.
Impure wrapper function for f_dst_norm_pdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location (mean) |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (standard deviation) |
Percent point function/quantile function for normal distribution.
The probability (p
)must be between 0.0 and 1.0.
The location parameter (mu
) is an optional argument and will default to 0.0 if not passed.
The scale parameter (sigma
) is an optional argument. If passed, it must be non-zero positive.
It will default to 1.0 if not passed.
The procedure uses bisection method. Conditions p=0.0 and p=1.0 cannot return negative and positive infinity; will return large negative or positive numbers (highly dependent on the tolerance threshold).
Impure wrapper function for f_dst_norm_ppf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | p |
probability between 0.0 - 1.0 |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location (mean) |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (standard deviation) |
sample position
Principal Component Analysis (PCA) or Empirical Orthogonal Function (EOF) analysis is a procedure that reduces the dimensionality of multivariate data by identifying a set of orthogonal vectors (eigenvectors or EOFs) that represent directions of maximum variance in the dataset. EOF analysis is often used interchangably with the geographically weighted PCA. As they are mathematically identical, a single pca procedure is offered with optional arguments and outputs that also makes it usable as a classic EOF analysis.
For a classic PCA, the input matrix x
is assumed to contain observations in rows
and variables in columns.
For a classic EOF analysis, the input matrix x
is assumed to contain time in rows
and space in columns.
Optionally, the data can be standardised (using the correlation matrix) and/or column-wise weights can be applied prior to analysis. While the latter is unusual for a standard PCA, it is common for EOF analysis (geographically weighted PCA as often applied in geographical sciences).
The covariance or correlation matrix is computed as:
where:
- is the preprocessed (centred and optionally standardised) data matrix,
- is the number of observations (rows in x
).
A symmetric eigen-decomposition is performed: where: - contains the eigenvectors (EOFs), - is a diagonal matrix of eigenvalues representing variance explained.
The principal components (PCs) are given by:
The explained variance for each component is computed as:
EOFs may optionally be scaled for plotting:
This subroutine uses eigh
from the stdlib_linalg
module to compute
eigenvalues and eigenvectors of the symmetric covariance matrix.
x(m,n)
: Input data matrix (observations × variables)m
: Number of rows (observations)n
: Number of columns (variables)opt
: (Optional) Use 0 for covariance matrix, 1 for correlation matrix (default: 1)wt(n)
: (Optional) Column weights (default: equal weights)pc(m,n)
: Principal components (scores)eof(n,n)
: EOFs / eigenvectors (unweighted)ev(n)
: Eigenvalues (explained variance)r2(n)
: (Optional) Percentage of variance explained by each componenteof_scaled(n,n)
: (Optional) EOFs scaled by square root of eigenvaluesThe number of valid EOF/PC modes is determined by the number of non-zero eigenvalues. Arrays are initialised to zero and populated only where eigenvalues are strictly positive.
Empirical Orthogonal Function (EOF) analysis / Principal Component Analysis (PCA)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(m,n) |
input data |
||
integer(kind=i4), | intent(in) | :: | m |
number of rows |
||
integer(kind=i4), | intent(in) | :: | n |
number of columns |
||
integer(kind=i4), | intent(in), | optional | :: | opt |
0 = covariance, 1 = correlation |
|
real(kind=wp), | intent(in), | optional | :: | wt(n) |
optional weights (default = 1.0/n) |
|
real(kind=wp), | intent(out) | :: | pc(m,n) |
principal components |
||
real(kind=wp), | intent(out) | :: | eof(n,n) |
EOFs/eigenvectors (unweighted) |
||
real(kind=wp), | intent(out) | :: | ev(n) |
eigenvalues |
||
real(kind=wp), | intent(out), | optional | :: | eof_scaled(n,n) |
EOFs/eigenvectors scaled for plotting |
|
real(kind=wp), | intent(out), | optional | :: | r2(n) |
explained variance (%) |
Computes Pearson correlation coefficient (PCC).
where is the Pearson correlation coefficient for vectors x
and y
,
is the covariance of x
and y
, and
and are the standard deviations of x
and y
.
Vectors x
and y
must be the same size.
Impure wrapper function for f_sts_trend_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in) | :: | y(:) |
y vector (assumed size array) |
Pearson correlation coefficient
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.
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 |
The ranks sum test (Wilcoxon rank-sum test or Mann–Whitney U test) is a non-parametric test to determine if two independent samples and are have the same distribution. It can be regarded as the non-parametric equivalent of the 2-sample t-test.
The null hypothesis and alternative hypothesis can be written as: : the distributions of and are equal. : the distributions of and are not equal.
The Mann–Whitney U statistic is calculated for each sample as follows: where is the sum of ranks of sample set and is the sample size of sample set . The final U statistic is:
The procedure takes into consideration tied ranks.
Impure wrapper procedure for s_tst_ranksum_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1(:) |
x1 vector (samples) |
||
real(kind=wp), | intent(in) | :: | x2(:) |
x2 vector (samples) |
||
real(kind=wp), | intent(out) | :: | u |
U statistic |
||
real(kind=wp), | intent(out) | :: | p |
p-value |
||
character(len=*), | intent(in), | optional | :: | h1 |
option: "two" (default), "lt", or "gt" |
Read CSV file directly into dataframe.
Read CSV file directly into dataframe.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | infile |
read csv file |
||
type(fsml_typ_df), | intent(inout) | :: | df |
dataframe |
||
logical, | intent(in), | optional | :: | labelcol |
true if first column contains row labels |
|
logical, | intent(in), | optional | :: | labelrow |
true if first row contains column lavels |
|
character(len=1), | intent(in), | optional | :: | delimiter |
single char delimiter |
The 1-sample Wilcoxon signed rank test is a non-parametric test that determines if data comes from a symmetric population with centre . It can be regarded as a non-parametric version of the 1-sample t-test.
If the data consists of independent and similarly distributed samples from distribution , the null hypothesis can be expressed as:
is symmetric around .
The default alternative hypothesis is two-sided and also be
set explicitly (h1 = "two"
). It can be expressed as:
is symmetric around
If the alternative hypothesis is set to "greater than" (h1 = "gt"
), it is:
is symmetric around
If the alternative hypothesis is set to "less than" (h1 = "lt"
), it is:
is symmetric around
The test statistic is the smaller of the sum of positive and negative signed ranks:
The procedure takes into consideration tied ranks.
Impure wrapper procedure for s_tst_signedrank_1s_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (samples) |
||
real(kind=wp), | intent(in) | :: | mu0 |
population mean (null hypothesis expected value) |
||
real(kind=wp), | intent(out) | :: | w |
W statistic (sum of signed ranks) |
||
real(kind=wp), | intent(out) | :: | p |
p-value |
||
character(len=*), | intent(in), | optional | :: | h1 |
: "two" (default), "lt", "gt" |
The Wilcoxon signed rank test is a non-parametric test that determines if two related paired samples come from the same distribution. It can be regarded as a non-parametric version of the paired t-test.
The Wilcoxon signed rank test is mathematically equivalent to the 1-sample Wilcoxon signed rank test conducted on the difference vector with set to zero. Consequently, the the null hypothesis can be expressed as:
Samples are symmetric around .
The default alternative hypothesis is two-sided and also be
set explicitly (h1 = "two"
). It can be expressed as:
Samples are symmetric around
If the alternative hypothesis is set to "greater than" (h1 = "gt"
), it is:
Samples are symmetric around
If the alternative hypothesis is set to "less than" (h1 = "lt"
), it is:
Samples are symmetric around
The procedure takes into consideration tied ranks.
Impure wrapper procedure for s_tst_signedrank_2s_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1(:) |
sample 1 (paired data) |
||
real(kind=wp), | intent(in) | :: | x2(:) |
sample 2 (paired data) |
||
real(kind=wp), | intent(out) | :: | w |
W statistic (sum of signed ranks) |
||
real(kind=wp), | intent(out) | :: | p |
p-value |
||
character(len=*), | intent(in), | optional | :: | h1 |
: "two" (default), "lt", "gt" |
Computes the population or sample standard deviation (depending on passed arguments).
where is the variance of vector x
.
(ddof
) can also be passed and serves as a degrees of freedom adjustment
when the variance is caulculated. (ddof = 0.0
for population standard deviation,
ddof = 1.0
for sample standard deviation)
Impure wrapper function for f_sts_std_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in), | optional | :: | ddof |
delta degrees of freedom |
standard deviation
Cumulative distribution function for student t distribution.
The value for degrees of freedom (df
) must be 1.0 or higher.
The location parameter (mu
) is an optional argument and will default to 0.0 if not passed.
The scale parameter (sigma
) is an optional argument. If passed, it must be non-zero positive.
It will default to 1.0 if not passed.
The tail option (tail
) is an optional argument. If passed, it must be one of the following:
"left", "right", "two", or "confidence". If not passed, it will default to "left".
Impure wrapper function for f_dst_t_cdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location (mean) |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (standard deviation) |
|
character(len=*), | intent(in), | optional | :: | tail |
tail options |
returned probability integral
Probability density function for student t distribution.
Uses intrinsic gamma function (Fortran 2008 and later).
where = degrees of freedom (df
) and is the gamma function.
The value for degrees of freedom (df
) must be 1.0 or higher.
The location parameter (mu
) is an optional argument and will default to 0.0 if not passed.
The scale parameter (sigma
) is an optional argument. If passed, it must be non-zero positive.
It will default to 1.0 if not passed.
Impure wrapper function for f_dst_t_pdf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location (~mean) |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (~standard deviation) |
Percent point function/quantile function for t distribution.
Procedure uses bisection method. Conditions p=0.0 and p=1.0 cannot return negative and positive infinity; will return large negative or positive numbers (highly dependent on the tolerance threshold).
The value for degrees of freedom (df
) must be 1.0 or higher.
The location parameter (mu
) is an optional argument and will default to 0.0 if not passed.
The scale parameter (sigma
) is an optional argument. If passed, it must be non-zero positive.
It will default to 1.0 if not passed.
Impure wrapper function for f_dst_t_ppf_core
.
Handles optional arguments and invalid values for arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | p |
probability between 0.0 - 1.0 |
||
real(kind=wp), | intent(in) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | mu |
distribution location (mean) |
|
real(kind=wp), | intent(in), | optional | :: | sigma |
distribution dispersion/scale (standard deviation) |
sample position
Computes regression coefficient/trend.
where is the slope of the regression line (linear trend),
is the covariance of x
and y
, and
is the variance of x
.
Vectors x
and y
must be the same size.
Impure wrapper function for f_sts_trend_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in) | :: | y(:) |
y vector (assumed size array) |
trend/regression slope
The 1-sample t-test determines if the sample mean has the value specified in the null hypothesis.
The null hypothesis and alternative hypothesis can be written as: : , and :
The test statstic is calculated as follows: where is the sample mean, is the sample standard deviation, is the sample size, and is the population mean.
The degrees of freedom is calculated as follows:
Impure wrapper procedure for s_tst_ttest_1s_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (samples) |
||
real(kind=wp), | intent(in) | :: | mu0 |
population mean (null hypothesis expected value) |
||
real(kind=wp), | intent(out) | :: | t |
test statistic |
||
real(kind=wp), | intent(out) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(out) | :: | p |
p-value |
||
character(len=*), | intent(in), | optional | :: | h1 |
option: two (default), le, ge |
The 2-sample t-test determines if two population means and are the same. The procedure can handle 2-sample t-tests for equal variances and Welch's t-tests for unequal variances.
The null hypothesis and alternative hypothesis can be written as: : , and :
The procedure defaults to Welch's t-test for unequal variances if eq_var
is not specified.
In this case, the test statstic is calculated as follows:
where and are the sample means
and are the sample standard deviations, and
and are the sample sizes.
The degrees of freedom is approximated with the Welch–Satterthwaite equation:
If variances are assumed to be equal (eq_var = .true.
),
the procedure conducts a 2 sample t-test for equal variances, using the pooled standard
deviation to calculate the t-statistic:
In case of assumed equal variances, the degrees of freedom is calculated as follows:
Impure wrapper procedure for s_tst_ttest_2s_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1(:) |
x1 vector (samples) |
||
real(kind=wp), | intent(in) | :: | x2(:) |
x2 vector (samples) |
||
real(kind=wp), | intent(out) | :: | t |
test statistic |
||
real(kind=wp), | intent(out) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(out) | :: | p |
p-value |
||
logical, | intent(in), | optional | :: | eq_var |
true if equal variances assumed |
|
character(len=*), | intent(in), | optional | :: | h1 |
option: two (default), le, ge |
The paired sample t-test (or dependent sample t-test) determines if the mean difference between two sample sets are zero. It is mathematically equivalent to the 1-sample t-test conducted on the difference vector with .
The null hypothesis and alternative hypothesis can be written as: : , and :
The test statstic is calculated as follows: where is the mean of the differences between the sample sets, is the standard deviation of the differences, and is the number of paired samples.
The degrees of freedom is calculated as follows:
Impure wrapper procedure for s_tst_ttest_paired_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1(:) |
x1 vector (samples) |
||
real(kind=wp), | intent(in) | :: | x2(:) |
x2 vector (samples); must be same length as x1 |
||
real(kind=wp), | intent(out) | :: | t |
test statistic |
||
real(kind=wp), | intent(out) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(out) | :: | p |
p-value |
||
character(len=*), | intent(in), | optional | :: | h1 |
option: two (default), le, ge |
Computes the population or sample variance (depending on passed arguments).
where is the size of (or number of observations in) vector x
,
are individual elements in x
,
(ddof
) is a degrees of freedom adjustment
(ddof = 0.0
for population variance, ddof = 1.0
for sample variance), and
is the arithmetic mean of x
.
Impure wrapper function for f_sts_var_core
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in), | optional | :: | ddof |
delta degrees of freedom |
variance