I have forgotten

• https://me.yahoo.com
COST (GBP)
0.50
0.50
0

# Pearson

viewed 2470 times and licensed 100 times
Calculates the Pearson product for a given set of data.
Controller: CodeCogs
Contents

C++

## Pearson

 template doublepearson( int N T* data T* data1 )
Returns the Pearson product moment correlation coefficient, r, a dimensionless index that ranges from -1.0 to 1.0 inclusive and reflects the extent of a linear relationship between two data sets.

The formula for the Pearson product moment correlation coefficient, r, is:

where
•  and  are the sample mean.

### Example 1

#include <codecogs/statistics/moments/pearson.h>
#include <iostream>
int main()
{
double x[5] = {4 , 5 , 8 , 6 , 3};
double y[5] = {6 , 7 , 8 , 3 , 2};
double rez = Stats::Moments::pearson<double>(5,x,y);
std::cout << "The Pearson product is: " << rez << std::endl;
return 0;
}
Output:
The Pearson product is: 0.592494

### Parameters

 N the size of the array data is a set of independent values given as an array data1 is a set of dependent values given as an array

### Returns

returns the Pearson product moment correlation coefficient

### 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.