Skip to content

Commit

Permalink
pearson cor: use formula that's linear in weights (#2)
Browse files Browse the repository at this point in the history
* use formula that's linear in weights

* try to fix travis osx
  • Loading branch information
tnagler committed Feb 7, 2019
1 parent 3d45196 commit 6df8f6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -41,7 +41,6 @@ install:

### OSX
- if [ $TRAVIS_OS_NAME == osx ]; then /usr/bin/yes | pip2 uninstall numpy; fi
- if [ $TRAVIS_OS_NAME == osx ]; then rm /usr/local/include/c++; fi # https://github.com/Homebrew/brew/issues/1742#issuecomment-277308817
- if [ $TRAVIS_OS_NAME == osx ]; then brew update; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew install gcc lcov eigen doxygen graphviz; fi

Expand Down
7 changes: 3 additions & 4 deletions include/wdm/prho.hpp
Expand Up @@ -44,10 +44,9 @@ inline double prho(std::vector<double> x,
// compute variances and covariance
double v_x = 0.0, v_y = 0.0, cov = 0.0, wi_sq;
for (size_t i = 0; i < n; i++) {
wi_sq = weights[i] * weights[i];
v_x += x[i] * x[i] * wi_sq;
v_y += y[i] * y[i] * wi_sq;
cov += x[i] * y[i] * wi_sq;
v_x += x[i] * x[i] * weights[i];
v_y += y[i] * y[i] * weights[i];
cov += x[i] * y[i] * weights[i];
}

// compute correlation
Expand Down

0 comments on commit 6df8f6f

Please sign in to comment.