Skip to content

Commit e473028

Browse files
committed
Fixed a bug in the calculation of the linear correlation coefficient while estimating the parameters of LinearGaussianCPD.
1 parent cfee362 commit e473028

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pybnesian/learning/parameters/mle_LinearGaussianCPD.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ typename LinearGaussianCPD::ParamsClass _fit_2parent(const DataFrame& df,
9999

100100
auto cov_xx = (dx1 * dx2).sum() / (rows - 1);
101101

102-
auto singular2 = var_x2 < util::machine_tol || std::abs(cov_xx / (var_x1 * var_x2)) > (1 - util::machine_tol);
102+
auto singular2 =
103+
var_x2 < util::machine_tol || std::abs(cov_xx / std::sqrt(var_x1 * var_x2)) > (1 - util::machine_tol);
103104

104105
auto mean_y = y->mean();
105106
auto dy = (y->array() - mean_y);

0 commit comments

Comments
 (0)