it.grypho.scala.leonardo.statistics
Members list
Type members
Classlikes
The two-sample statistics.
The two-sample statistics.
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- enum
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
PairStatKind.type
The single-sample statistics.
The single-sample statistics.
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The inference tests.
The inference tests.
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A statistic of two equally long samples.
A statistic of two equally long samples.
Value parameters
- a
-
the first sample
- b
-
the second
- kind
-
the statistic
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Ordinary least squares: regress(X, y).
Ordinary least squares: regress(X, y).
Returns the p × 1 coefficient vector. No intercept column is added: a constant term is a column of ones the caller supplies, because a silently inserted column would make regress compute something other than what was written, with no way to opt out.
Value parameters
- x
-
the design matrix
- y
-
the response vector
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
A statistic of one argument, which may be a sample or a distribution.
A statistic of one argument, which may be a sample or a distribution.
Dispatching on the argument is what lets mean and variance mean one thing each. A distribution delegates to probability, which owns its own moments; a matrix is treated as a sample. This is why statistics imports probability and not the reverse.
Note the n/n − 1 distinction that follows from the dispatch: variance(sample) is the unbiased estimator, while variance(distribution) is the population variance, because a distribution is not a sample and has no n to correct for. See the package overview.
Value parameters
- arg
-
the sample or distribution
- kind
-
the statistic
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
An inference test.
An inference test.
Thin wrappers: the work was in the incomplete beta and gamma kernels and in the distribution carrier, both of which already existed. What this adds is the test statistics themselves and the routing.
Value parameters
- a
-
the sample (or observed counts)
- b
-
the null mean, the confidence level, or the expected counts
- kind
-
the test
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
The fitted values X·β.
The fitted values X·β.
Value parameters
- beta
-
the coefficients
- x
-
the design matrix
Attributes
Fits y ≈ X·β by ordinary least squares.
Fits y ≈ X·β by ordinary least squares.
No intercept is added. A constant term is a column of ones in X, which the caller supplies — silently inserting one would make regress mean something different from what was written, and there is no way to opt out of a hidden column.
Value parameters
- x
-
the design matrix,
n × p, withn ≥ p - y
-
the response,
n × 1or1 × n
Attributes
- Returns
-
the
p × 1coefficient vector, orNonewhen the shapes do not conform or the design is rank-deficient (qrDecomposerefuses it, so nonsense is not produced)
The residual sum of squares of a fit, which the inference tier needs.
The residual sum of squares of a fit, which the inference tier needs.
Value parameters
- beta
-
the coefficients
- x
-
the design matrix
- y
-
the response,
n × 1
Attributes
The Pearson correlation coefficient.
The Pearson correlation coefficient.
Scale-invariant, so the n − 1 cancels between the covariance and the two standard deviations — this is the one statistic here for which the population/sample choice makes no difference at all.
Value parameters
- env
-
supplies the working precision
- xs
-
the first sample
- ys
-
the second, which must be the same length
Attributes
- Returns
-
the correlation in
[-1, 1], orNoneif either sample is constant
The covariance of two equally long samples, dividing by n − 1.
The covariance of two equally long samples, dividing by n − 1.
Value parameters
- env
-
supplies the reduction policy
- xs
-
the first sample
- ys
-
the second, which must be the same length
Attributes
- Returns
-
the covariance — exact when both samples are
The arithmetic mean.
The arithmetic mean.
Value parameters
- env
-
supplies the reduction policy for the exact path
- xs
-
the sample, which must be non-empty
Attributes
- Returns
-
the mean — exact when the sample is
Reads an evaluated expression as a sample: every entry of a matrix, row-major.
Reads an evaluated expression as a sample: every entry of a matrix, row-major.
Accepts both carriers, which matters for exact input: an exactly-written matrix stays a symbolic _Matrix rather than collapsing to the dense one, and that is precisely the case where an exact statistic is worth having.
Value parameters
- r
-
the evaluated argument
Attributes
- Returns
-
the entries, or
Nonewhen the argument is not a matrix of values
The standard deviation — the square root of sampleVariance.
The standard deviation — the square root of sampleVariance.
A square root is not closed over the rationals, so an exact sample gives an exact variance but only a working-precision standard deviation. That is the same contract every irrational result in the library carries, and it goes through the same kernel.
Value parameters
- ddof
-
1for the sample standard deviation,0for the population one - env
-
supplies the working precision
- xs
-
the sample
Attributes
The variance, dividing by n − ddof.
The variance, dividing by n − ddof.
Two-pass, deliberately. The textbook one-pass form E[X²] − E[X]² subtracts two nearly equal quantities whenever the sample has a large mean relative to its spread, and loses most of its significant digits doing so — the same catastrophic cancellation that already cost this project the quadratic formula's small root. Computing the mean first and then summing squared deviations has no such subtraction in it.
Value parameters
- ddof
-
1for the unbiased sample variance,0for the population variance - env
-
supplies the reduction policy for the exact path
- xs
-
the sample
Attributes
- Returns
-
the variance — exact when the sample is