Sample Covariance Calculation and Interpretation
Install and import#
npm install fintech-algorithmsimport { sampleCovarianceCalculationAndInterpretation } from "fintech-algorithms/financial-mathematics-statistics-and-data-foundations/dependence-regression-and-model-foundations/sample-covariance-calculation-and-interpretation";Signature#
sampleCovarianceCalculationAndInterpretation(input)Worked example#
verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.
Input#
{
"x": [1, 2, 3, 4, 5, 6],
"y": [2, 3, 5, 4, 6, 7],
"groups": ["A", "A", "A", "B", "B", "B"],
"predictX": 7,
"otherPredictor": [2, 4, 5, 8, 9, 13]
}Call#
sampleCovarianceCalculationAndInterpretation(input)Returns#
object with 2 fields: sampleCovariance, direction
{
"sampleCovariance": 3.3,
"direction": "positive"
}Diagrams#
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- Linear Least Squares Regression — NIST/SEMATECH e-Handbook
- Correlation — NIST/SEMATECH e-Handbook
- Historical-example decision