Skip to content

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 errors stddev/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

NameTypeAttributesDescription
meanreal(kind=R8P)Mean.
stddevreal(kind=R8P)Population standard deviation.
ssdreal(kind=R8P)Sample standard deviation.
skewnessreal(kind=R8P)Skewness.
kurtosisreal(kind=R8P)Kurtosis.
adevreal(kind=R8P)Mean absolute deviation.
mean_errreal(kind=R8P)Standard error of the mean.
stddev_errreal(kind=R8P)Standard error of the standard deviation.
skewness_errreal(kind=R8P)Standard error of the skewness.
kurtosis_errreal(kind=R8P)Standard error of the kurtosis.
sumreal(kind=R8P)Sum.
sumsqreal(kind=R8P)Sum of squares.
minreal(kind=R8P)Minimum.
maxreal(kind=R8P)Maximum.
medianreal(kind=R8P)Median.
lo_quartilereal(kind=R8P)Lower quartile.
up_quartilereal(kind=R8P)Upper quartile.
index_mininteger(kind=I4P)0-based index of the minimum.
index_maxinteger(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

NameTypeAttributesDescription
recordsinteger(kind=I4P)Points analysed.
invalidinteger(kind=I4P)Records with an undefined value.
headersinteger(kind=I4P)Column header records.
blankinteger(kind=I4P)Blank lines.
blocksinteger(kind=I4P)Data blocks (separated by two blank lines).
outofrangeinteger(kind=I4P)Points outside the ranges.
columnsinteger(kind=I4P)Columns of the file.
twologicalTwo columns analysed.
xtype(stats_column)First column of two.
ytype(stats_column)The column, or the second of two.
slopereal(kind=R8P)Least squares slope.
interceptreal(kind=R8P)Least squares intercept.
slope_errreal(kind=R8P)Standard error of the slope.
intercept_errreal(kind=R8P)Standard error of the intercept.
correlationreal(kind=R8P)Correlation coefficient.
sumxyreal(kind=R8P)Sum of the products.
pos_min_yreal(kind=R8P)x of the y minimum.
pos_max_yreal(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.

fortran
subroutine stats_report(r, unit, formatted)

Arguments

NameTypeIntentAttributesDescription
rtype(stats_result)inStatistics.
unitinteger(kind=I4P)inOutput unit.
formattedlogicalinScreen layout.

Call graph

Functions ​

stats_one ​

gnuplot stats ... using N on the values y (at least one).

Attributes: pure

Returns: type(stats_result)

fortran
function stats_one(y) result(r)

Arguments

NameTypeIntentAttributesDescription
yreal(kind=R8P)inValues.

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)

fortran
function stats_two(x, y) result(r)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inFirst column.
yreal(kind=R8P)inSecond column.

Call graph

analyze ​

gnuplot's analyze_sgl_column on the values v (at least one).

Attributes: pure

Returns: type(stats_column)

fortran
function analyze(v) result(s)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inValues.

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)

fortran
function sorted(v) result(order)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inValues.

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=:)

fortran
function fmt(v) result(text)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inValue.

Call graph

g4 ​

%.4g, nan for NaN as C prints it.

Attributes: pure

Returns: character(len=:)

fortran
function g4(v) result(text)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inValue.

Call graph

f6 ​

%f.

Attributes: pure

Returns: character(len=:)

fortran
function f6(v) result(text)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inValue.

Call graph

text right justified in width characters (%*s).

Attributes: pure

Returns: character(len=:)

fortran
function right(text, width) result(padded)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText.
widthinteger(kind=I4P)inField width.

Call graph

nan ​

A quiet NaN.

Attributes: pure

Returns: real(kind=R8P)

fortran
function nan() result(v)

Call graph

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.