Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Zscore
//g++ 7.4.0 //write a program that computes and prints mean,standard deviation and z-scores of the input data //this code is created by Rezaul Hoque on August 05,2021;contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> #include <cmath> using namespace std; const int n=8; float sd(float [],float); void zscore(float [],float,float); float sd(float a[],float mean){ int i,psd,sd; for(i=0;i<n;i++) psd=(a[i]-mean)*(a[i]-mean); sd=sqrt(psd)/(n-1); return sd; } void zscore(float a[],float mean,float sd){ float z[n]; for(int i=0;i<n;i++) z[i]= (a[i]-mean)/sd; for(int i=0;i<n;i++){ cout<<" "<<*(z+i); cout<<"\n"; } } int main(){ float a[]={0.01,0.02,0.03,0.04,0.05,0.06,0.15,0.25}; cout<<" Input data are:\n"; for(int i=0;i<n;i++){ cout<<*(a+i)<<" "; } float sum=0,mean; for(int i=0;i<n;i++) sum += a[i]; mean = sum/n; cout<<"\nMean: "<<mean<<" \n"; cout<<"Standard Deviation: "<<sd(a,mean)<<"\n" ; float m= sd(a,mean); cout<<"Z-scores: \n"; zscore(a,mean,m); return 0; }
run
|
edit
|
history
|
help
0
Изволов#8
float precision test
Finalproject
2015(M2)Mod.
Dar
Dar
qsort
Destroy It!
Perf measurement
10 wizards-DFS_vector