File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed
Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ DataPearsonCorrelationMethod class >> between: x and: y [
1111 | xDeviation yDeviation |
1212 x size = y size ifFalse: [ SizeMismatch signal : ' Correlation can not be calculated for two series of different size' ].
1313
14- xDeviation := (x values replaceAll: nil with: 0 ) - (x sum / x size) .
15- yDeviation := (y values replaceAll: nil with: 0 ) - (y sum / y size) .
14+ xDeviation := (x values replaceAll: nil with: 0 ) - x average .
15+ yDeviation := (y values replaceAll: nil with: 0 ) - y average .
1616
1717 ^ (xDeviation * yDeviation) sum / ((xDeviation ** 2 ) sum * (yDeviation ** 2 ) sum) sqrt
1818]
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ DataFrameStatsTest >> testCorrelationMatrixWithNils [
7373 df := DataFrame withRows: #( #( 1 1 ) #( 2 nil ) #( nil 3 ) #( 4 4 ) ).
7474 df columnNames: #( dogs cats ) .
7575
76- expectedCorrelationMatrix := DataFrame withRows: #( #( 1 0.3207134902949093 ) #( 0.3207134902949093 1 ) ).
76+ expectedCorrelationMatrix := DataFrame withRows: #( #( 1 0.4174555390689118 ) #( 0.4174555390689118 1 ) ).
7777 expectedCorrelationMatrix columnNames: #( dogs cats ) .
7878 expectedCorrelationMatrix rowNames: #( dogs cats ) .
7979
You can’t perform that action at this time.
0 commit comments