I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.50
sub units 0.50
+
0

Pearson

viewed 2475 times and licensed 101 times
Calculates the Pearson product for a given set of data.
Controller: CodeCogs

Dependents

Info

Interface

C++

Pearson

 
template<class T> doublepearsonintN
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
  • \inline \overline{x} and \inline \overline{y} 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

Nthe size of the array
datais a set of independent values given as an array
data1is 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.