Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
NonparaSign
//g++ 7.4.0 //Nonparametric Test: The Sign Test //code is created by Rezaul Hoque on January 28,2021 //please contact at jewelmrh@yahoo.com #include <iostream> #include <string> #include <cmath> using namespace std; int plusCount(string [], int,string ); int minCount(string [], int,string); int plusCount(string b[], int n, string plus) { int theCount=0; for (int i=0;i<n;i++) if(b[i]== "plus") ++theCount; return theCount; } int minCount(string b[], int n, string minus) { int minCount=0; for (int i=0;i<n;i++) if(b[i]== "minus") ++minCount; return minCount; } int main() { int n=24, x= 250; string plus,minus; float a[n]={271,230,198,275,282,225,284,219,253,216,262,288,236,291,253,224,264,295,211,252,294,243,272,268}; string * b = new string[n]; for(int i=0;i<n; i++){ if (a[i]-x >0) b[i] ="plus"; else if (a[i]-x <0) b[i] ="minus"; else b[i]="zero"; } for(int i=0;i<n; i++){ cout <<" "<<b[i]<<endl; } cout <<"There are "<<plusCount(b,n,plus)<< " pluses and "<<minCount(b,n,minus)<< " minuses.\n"; float anysign=15, p=0.5,q=0.5, zed; zed = (anysign-0.5-n*p)/sqrt(n*p*q); cout <<" z =\t"<<zed<<endl; if (zed>1.645) cout <<"Reject the null hypothesis at 0.05 level.\n"; else cout <<"Accept the null hypothesis at 0.05 level."; delete [] b; return 0; }
run
|
edit
|
history
|
help
0
hack qus
Count of factors
Menu Combination Sum
Undefined behaviour
C++
tree
День Программиста
simple use of templete
Dar
CodeChef P1 MATMIN1