qreal Statistics::correlationCoefficient(const Vector &X, const Vector &Y) { Vector Xc = centeredRandomVariables(X); Vector Yc = centeredRandomVariables(Y); qreal Dx = sumOfSquares(Xc); qreal Dy = sumOfSquares(Yc); qreal rxy = 0.0; for (qint32 i = 0; i < X.count(); ++i) rxy += Xc.at(i)*Yc.at(i); return rxy/qPow(Dx*Dy, 0.5); }
int main() { long difference; difference = squareOfSum(LIMIT) - sumOfSquares(LIMIT); printf("The difference is: %ld\n", difference); return 0; }
int main(void) { int result = squareOfSum(100) - sumOfSquares(100); printf("%d\n", result); return result; // Answer: 25164150 }
int main(){ int sum_square, square_sum, difference; sum_square = sumOfSquares(); square_sum = squareOfSums(); difference = square_sum - sum_square; printf("%d\n", difference); return 0; }
int main(void) { // sum the diagonals of a 1001x1001 spiral // excluding the first 1 each level has a box with 4 corners // c4 => (2x + 1)^2 - 0x // c3 => (2x + 1)^2 - 2x // c2 => (2x + 1)^2 - 4x // c1 => (2x + 1)^2 - 6x // avg => (2x +1)^2 - 3x // => 4x^2 + x + 1 // each level sum is 4(4x^2 + x + 1) // There are 500 levels plus the first 1 uint64_t result = 1; result += 4 * 500; result += 4 * sumOfNumbers(500); result += 16 * sumOfSquares(500); std::cout << result << std::endl; }
/** Test matrix classes */ int main() { hilbert(); submatrix(); sumOfSquares(); indexDenseSubmatrix(); spGetCol(); spGetRow(); spTimes(); spIndTimes(); sprGetCol(); sprGetRow(); sprTimes(); sprIndTimes(); Symmetry(); return 0; }
int main() { printf("%lu\n", squareOfSum(NUM) - sumOfSquares(NUM)); return 0; }
int main() { printf("%lld\n", squareOfSums(100) - sumOfSquares(100)); return 0; }
int64_t squaresDiff(int64_t n){return squareOfSum(n)-sumOfSquares(n);}
qreal Statistics::variance(const Vector &X) { Vector Xc = centeredRandomVariables(X); qreal Dx = sumOfSquares(Xc); return Dx /= (X.count() - 1); }