Skip to content

Commit

Permalink
[sysid] Fix SSTO calculation
Browse files Browse the repository at this point in the history
I misread the slide the equation came from.
  • Loading branch information
calcmogul committed Jan 23, 2024
1 parent 9d55941 commit fbf51d6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sysid/src/main/native/cpp/analysis/OLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ OLSResult OLS(const Eigen::MatrixXd& X, const Eigen::VectorXd& y) {
//
// SSTO = yᵀy - 1/n yᵀJy
//
// Let J = I.
//
// SSTO = yᵀy - 1/n yᵀy
// SSTO = (n − 1)/n yᵀy
double SSTO = (n - 1.0) / n * (y.transpose() * y).value();
// where J is a matrix of ones.
double SSTO =
(y.transpose() * y - 1.0 / y.rows() * y.transpose() *
Eigen::MatrixXd::Ones(y.rows(), y.rows()) * y)
.value();

// R² or the coefficient of determination, which represents how much of the
// total variation (variation in y) can be explained by the regression model
Expand Down

0 comments on commit fbf51d6

Please sign in to comment.