Statistics › Moments ›
Covariance
Calculates the covariance of a given set of data
Controller: CodeCogs
Contents
Dependents
Interface
C++
Covariance
template<class T> doublecovariance( | int | n | |
T* | data | ||
T* | data1 | ) |
MISSING IMAGE!
1/covariance-6-965.png cannot be found in /users/1/covariance-6-965.png. Please contact the submission author.
Example 1
#include <codecogs/statistics/moments/covariance.h> #include <iostream> int main() { int x[5] = {2 , 4 , 8 , 9 , 3}; int y[5] = {3 , 5 , 7 , 2 , 9}; double cov = Stats::Moments::covariance<int>(5, x , y); std::cout << "The covariance of x and y is: " << cov << std::endl; return 0; }
Output:The covariance of x and y is: -1.64
Parameters
n the size of the first array and of the second array data the actual population data given as the first array data1 the second array
Returns
- the covariance of a given population
Authors
- Anca Filibiu (August 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.