Pearson product-moment correlation coefficient

  • Statistical simulation of the Pearson product-moment correlation coefficient with R-Project

     x1 <- c(rep(10,5),rep(25,5),rep(35,6),rep(45,10),rep(55,38) 
    ,rep(65,30) ,rep(75,20),rep(85,4),rep(95,2));
     
    cvp <- function(x) {
     ni<- table(x);
    n<-sum(ni);
    m1<- mean(x);
    s1 <-sd(x)*sqrt((n-1)/n);
    cv<- s1/abs(m1);
    cv
      }
    
    cvp(x1)
    
    [1] 12.52664
    
    



  • Statistical simulation of the Pearson product-moment correlation coefficient with Mathematica
    x1 := Join[ConstantArray[10, 5], ConstantArray[25, 5], 
       ConstantArray[35, 6], ConstantArray[45, 10], ConstantArray[55, 38]
    , ConstantArray[65, 30], ConstantArray[75, 20], ConstantArray[85, 4]
    , ConstantArray[95, 2]];
       
    ni := Tally [x1];
    
    n := Sum[ni[[i, 2]], {i, Length[ni]}];
    
    m1:=Mean[x1]
    
    s1:=StandardDeviation[x1]  Sqrt[(n - 1)/n];
    
    cv:= (s1/Abs[m1])
    
    N[cv]
    
    0.297009