foresight_stats
foresight_stats, gnuplot's
stats: summary statistics of one or two columns.
A translation of gnuplot 6.0's stats.c, so that the values and the report are gnuplot's:
- population moments: the standard deviation from the centred sum of squares, skewness and kurtosis from the third and fourth centred moments (NaN when the variance is 0), the sample standard deviation
stddev * sqrt(n/(n-1)), the mean absolute deviation, the standard errorsstddev/sqrt(n),stddev/sqrt(2n),sqrt(6/n),sqrt(24/n); - the median and the quartiles of the sorted values as gnuplot's boxplots: an even count averages the two middle values, the quartiles average two values when the count is a multiple of 4;
- the minimum and the maximum with their 0-based index among the values (a sort that keeps equal values in order: the first of equal minima, the last of equal maxima);
- two columns: the least squares line
y = slope x + intercept, its standard errors (for more than 2 points; 0 for 2), the correlation, the sum of the products and the x of the y minimum and maximum.
stats computes them from Fortran arrays, stats_report writes gnuplot's report.
Source: src/lib/foresight_stats.F90
Dependencies
Contents
Derived Types
stats_column
Statistics of one column (gnuplot's STATS_mean, ... or STATS_mean_x, STATS_mean_y).
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
mean | real(kind=R8P) | Mean. | |
stddev | real(kind=R8P) | Population standard deviation. | |
ssd | real(kind=R8P) | Sample standard deviation. | |
skewness | real(kind=R8P) | Skewness. | |
kurtosis | real(kind=R8P) | Kurtosis. | |
adev | real(kind=R8P) | Mean absolute deviation. | |
mean_err | real(kind=R8P) | Standard error of the mean. | |
stddev_err | real(kind=R8P) | Standard error of the standard deviation. | |
skewness_err | real(kind=R8P) | Standard error of the skewness. | |
kurtosis_err | real(kind=R8P) | Standard error of the kurtosis. | |
sum | real(kind=R8P) | Sum. | |
sumsq | real(kind=R8P) | Sum of squares. | |
min | real(kind=R8P) | Minimum. | |
max | real(kind=R8P) | Maximum. | |
median | real(kind=R8P) | Median. | |
lo_quartile | real(kind=R8P) | Lower quartile. | |
up_quartile | real(kind=R8P) | Upper quartile. | |
index_min | integer(kind=I4P) | 0-based index of the minimum. | |
index_max | integer(kind=I4P) | 0-based index of the maximum. |
stats_result
gnuplot's STATS_* values: the file counts, one column (y) or two (x, y and their line).
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
records | integer(kind=I4P) | Points analysed. | |
invalid | integer(kind=I4P) | Records with an undefined value. | |
headers | integer(kind=I4P) | Column header records. | |
blank | integer(kind=I4P) | Blank lines. | |
blocks | integer(kind=I4P) | Data blocks (separated by two blank lines). | |
outofrange | integer(kind=I4P) | Points outside the ranges. | |
columns | integer(kind=I4P) | Columns of the file. | |
two | logical | Two columns analysed. | |
x | type(stats_column) | First column of two. | |
y | type(stats_column) | The column, or the second of two. | |
slope | real(kind=R8P) | Least squares slope. | |
intercept | real(kind=R8P) | Least squares intercept. | |
slope_err | real(kind=R8P) | Standard error of the slope. | |
intercept_err | real(kind=R8P) | Standard error of the intercept. | |
correlation | real(kind=R8P) | Correlation coefficient. | |
sumxy | real(kind=R8P) | Sum of the products. | |
pos_min_y | real(kind=R8P) | x of the y minimum. | |
pos_max_y | real(kind=R8P) | x of the y maximum. |
Interfaces
stats
Statistics of one column, stats(y), or of two, stats(x, y).
Module procedures: stats_one, stats_two
Subroutines
stats_report
gnuplot's report of r on unit: the screen layout (formatted, gnuplot's terminal) or the name-tab-value lines gnuplot writes to a set print file.
subroutine stats_report(r, unit, formatted)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
r | type(stats_result) | in | Statistics. | |
unit | integer(kind=I4P) | in | Output unit. | |
formatted | logical | in | Screen layout. |
Call graph
Functions
stats_one
gnuplot stats ... using N on the values y (at least one).
Attributes: pure
Returns: type(stats_result)
function stats_one(y) result(r)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
y | real(kind=R8P) | in | Values. |
Call graph
stats_two
gnuplot stats ... using N:M on the pairs (x, y), of the same size (at least one).
Attributes: pure
Returns: type(stats_result)
function stats_two(x, y) result(r)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | First column. | |
y | real(kind=R8P) | in | Second column. |
Call graph
analyze
gnuplot's analyze_sgl_column on the values v (at least one).
Attributes: pure
Returns: type(stats_column)
function analyze(v) result(s)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Values. |
Call graph
sorted
The permutation sorting v ascending, equal values in their order (a merge sort, as glibc's qsort).
Attributes: pure
Returns: integer(kind=I4P)
function sorted(v) result(order)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Values. |
Call graph
fmt
gnuplot's stats number: undefined for NaN, %11.4f (0 below 1e-14, magnitudes from 1e-6 to 1e6), else %11.5e.
Attributes: pure
Returns: character(len=:)
function fmt(v) result(text)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Value. |
Call graph
g4
%.4g, nan for NaN as C prints it.
Attributes: pure
Returns: character(len=:)
function g4(v) result(text)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Value. |
Call graph
f6
%f.
Attributes: pure
Returns: character(len=:)
function f6(v) result(text)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Value. |
Call graph
right
text right justified in width characters (%*s).
Attributes: pure
Returns: character(len=:)
function right(text, width) result(padded)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
width | integer(kind=I4P) | in | Field width. |
Call graph
nan
A quiet NaN.
Attributes: pure
Returns: real(kind=R8P)
function nan() result(v)Call graph