Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
NonparaH
//g++ 7.4.0 //Nonparametric Test: The Kruskal-Walis H Test //code is created by Rezaul Hoque on January 30,2021 //please contact at jewelmrh@yahoo.com #include <iostream> using namespace std; int tie(float [][5],int,int,float); int tie(float a[5][5], int n1,int n2,float x) { int thetie=0; for (int i=0;i<n1;i++) for (int j=0;j<n2;j++) if(a[i][j]== x ) ++thetie; return thetie; } int main () { int n=25; float sum1=0,sum2=0,sum3=0,sum4=0,sum5=0; float a[5][5]={17.5,21,24,1,6.5,21,6.5,12,6.5,2.5,10,25,14,23,21,2.5,11,9,14,4,14,16,19,17.5,6.5}; for( int j=0;j<5;j++){ sum1 += a[0][j]; sum2 += a[1][j]; sum3 += a[2][j]; sum4 += a[3][j]; sum5 += a[4][j]; } float sum1sq,sum2sq,sum3sq,sum4sq,sum5sq; sum1sq = sum1*sum1; sum2sq = sum2*sum2; sum3sq = sum3*sum3; sum4sq = sum4*sum4; sum5sq = sum5*sum5; float R[5]={sum1sq/5,sum2sq/5,sum3sq/5,sum4sq/5,sum5sq/5}; float H,sumR2=0; for(int i=0; i<5;i++) { sumR2 += R[i]; } H =( 12/(n*(n+1)))*sumR2-(3*(n+1)); cout <<"H = "<<H; cout<<endl; cout <<"There are "<<tie(a,5,5,2.5)<<" ties for 2.5.\n"; cout <<"There are "<<tie(a,5,5,6.5)<<" ties for 6.5.\n"; cout <<"There are "<<tie(a,5,5,14)<<" ties for 14.\n"; cout <<"There are "<<tie(a,5,5,17.5)<<" ties for 17.5.\n"; cout <<"There are "<<tie(a,5,5,21)<<" ties for 21.\n"; float T[5]={tie(a,5,5,2.5),tie(a,5,5,6.5),tie(a,5,5,14),tie(a,5,5,17.5),tie(a,5,5,21)}; float sumT=0,correctH, precH; for (int i=0;i<5;i++) { sumT += (T[i]*T[i]*T[i])-T[i]; } precH= 1-sumT/((n*n*n)-n); correctH=H/precH; cout <<" Corrected H = "<<correctH<<endl; cout <<"For (5-1)=4 degrees of freedom at 0.05 level of significance Chi-square = 9.49.\n"; if(correctH<9.49) cout <<"Accept the null hypothesis.\n"; else cout <<"Do not accept the null hypothesis."; return 0; }
run
|
edit
|
history
|
help
0
References Pt 1 C++
new delete malloc free
remove dublicates from string using recursion
aaaaaaaaaaaa
FindKthElementDivideConquer
lab17feb22x4B.cpp
arthi3.cpp
GenericPacker
Dar
Dijkstra